iphone - RestKit 更新到 xcode 4.4.1 后出现警告

标签 iphone ios xcode restkit

当我将 Xcode 更新到 4.4.1 时,它给了我 22 个关于使用 RestKit 库的警告。错误是这样的:

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

我通过替换修复了 18 个警告:

%lu 替换为 %u

object->isa替换为object_getClass(object)

keyObject->isa 替换为 object_getClass(keyObject)

还有 4 个警告我无法修复它,以下是警告及其描述:

文件名1:RKManagedObjectMappingOperation.m 警告线1:

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

警告说明1:

more '%' conversations than data arguments

文件名2:RKReachabilityObserver.m 警告线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]];

警告描述2:

format specifies type int but the argument has type NSString

文件名3:JSONKit.m 警告线3:

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); }

警告描述3:

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

文件名4:NSManagedObject+ActiveRecord.m 警告行 4:

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

警告描述4:

format specifies type id but the argument has type NSUInteger

如何解决?

最佳答案

警告1:

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

成为

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

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

它说“比数据参数更多的‘%’对话”意味着你有占位符,在本例中是%@,但没有参数来填充它们。因此,要么提供参数,要么删除占位符。

警告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]];

成为

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

注意 isMonitoringLocalWiFi=%d 部分获取的是 %@ 而不是 %d,因为您提供了一个字符串参数但有一个整数占位符.

警告 3:抱歉,无法帮助您解决此问题。也许在我查看代码后我会发布更新。

更新:尝试更改

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

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

警告4:

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

成为

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

请注意,第二个占位符应该是 %d 而不是 %@,因为您提供了一个整数,或者在本例中是一个 NSUInteger,即 [propDict count] 参数。

关于iphone - RestKit 更新到 xcode 4.4.1 后出现警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12326853/

相关文章:

ios - 设计决策属性与变量

ios - Swift - 向 UIWebView ScrollView 添加约束,以便与屏幕边缘的距离始终为 0

iphone - 如何在不使用 NSTimer 的情况下每 10 秒触发一次方法?

ios - 如何更新标签而不是覆盖?

objective-c - objective-c : Register file extension

iphone - 创建和取消 NSURLConnection

iphone - 调用取消方法后,NSURLConnection 仍然调用委托(delegate)

xcode - 如何 CFRelease 必须返回的 CGEventRef?

iPhone:如果未安装应用程序,则重定向到移动 safari 上的应用程序商店

iphone - 在 Linux 网络服务器上重新编码 iPhone/iPad Quicktime mov 文件以旋转视频