warnings after updating to x-code 4.4.1 for RestKit

When I updated X-Code to 4.4.1 It gives me 22 warning for using RestKit Library. The error was like this:

Direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()

I fixed 18 warnings by replacing:

Replace %lu with %u

Replace object->isa with object_getClass(object)

Replace keyObject->isa with object_getClass(keyObject)

There are 4 more warnings that I cannot fix it, here are the warnings following by its descriptions:

file Name 1: RKManagedObjectMappingOperation.m Warning Line1:

NSAssert(mapping, @"Attempted to connect relationship for keyPath '%@' without a relationship mapping defined.");

Warning Description1:

more '%' conversations than data arguments

File Name2: RKReachabilityObserver.m Warning Line2:

return [NSString stringWithFormat:@"<%@: %p host=%@ isReachabilityDetermined=%@ isMonitoringLocalWiFi=%d reachabilityFlags=%@>",
            NSStringFromClass([self class]), self, self.host, self.isReachabilityDetermined ? @"YES" : @"NO",
            self.isMonitoringLocalWiFi ? @"YES" : @"NO", [self reachabilityFlagsDescription]];

Warning description2:

format specifies type int but the argument has type NSString

File Name3: JSONKit.m Warning Line3:

if(JK_EXPECT_F(((id)keys[idx])->isa != encodeState->fastClassLookup.stringClass) && JK_EXPECT_F([(id)keys[idx] isKindOfClass:[NSString class]] == NO)) { jk_encode_error(encodeState, @"Key must be a string object."); return(1); }

Warning Description3:

Direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()

File Name4: NSManagedObject+ActiveRecord.m Warning Line 4:

RKLogError(@"Property '%@' not found in %@ properties for %@", propertyName, [propDict count], NSStringFromClass(self));

Warning description4:

format specifies type id but the argument has type NSUInteger

Any Idea how to fix it?

Answers


Warning 1:

NSAssert(mapping, @"Attempted to connect relationship for keyPath '%@' without a relationship mapping defined.");

becomes

NSAssert(mapping, @"Attempted to connect relationship for keyPath '%@' without a relationship mapping defined.", <<put the corresponding keyPath here >> );

or

NSAssert(mapping, @"Attempted to connect relationship for a keyPath without a relationship mapping defined.");

it said "more '%' conversations than data arguments" meaning that you have placeholders, in this case %@, but no arguments to fill them. So either provide an argument or delete the placeholder.

Warning 2:

return [NSString stringWithFormat:@"<%@: %p host=%@ isReachabilityDetermined=%@ isMonitoringLocalWiFi=%d reachabilityFlags=%@>",
        NSStringFromClass([self class]), self, self.host, self.isReachabilityDetermined ? @"YES" : @"NO",
        self.isMonitoringLocalWiFi ? @"YES" : @"NO", [self reachabilityFlagsDescription]];

becomes

return [NSString stringWithFormat:@"<%@: %p host=%@ isReachabilityDetermined=%@ isMonitoringLocalWiFi=%@ reachabilityFlags=%@>",
        NSStringFromClass([self class]), self, self.host, self.isReachabilityDetermined ? @"YES" : @"NO",
        self.isMonitoringLocalWiFi ? @"YES" : @"NO", [self reachabilityFlagsDescription]];

notice the isMonitoringLocalWiFi=%d part gets %@ instead of %d, because you provide a string argument but have an integer placeholder.

Warning 3: Sorry can't help you with this one. Probably after I take a look at the code I'll post an update.

update: try changing

((id)keys[idx])->isa

to

object_getClass( ((id)keys[idx]) )

Warning 4:

RKLogError(@"Property '%@' not found in %@ properties for %@", propertyName, [propDict count], NSStringFromClass(self));

becomes

RKLogError(@"Property '%@' not found in %d properties for %@", propertyName, [propDict count], NSStringFromClass(self));

notice the second placeholder should be %d and not %@ since you provide an integer or in this case a NSUInteger, i.e. [propDict count] argument.


Need Your Help

How to increase the loading speed of images on a web page which uses masonry js plugin

php javascript css ajax jquery-masonry

I am using Masonry plugin and am trying to display a gallery like web page.

Ember: how to retrieve validation errors after becameInvalid state?

ember.js ember-data

I use the RESTadpater to persist data. When a validation error occurs, I want to return a 422 response and then log the errors and show an indication next to each incorrect field.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.