我似乎能够正常启动restkit并使用传统的loadobjectsatresourcepath:delegate:方法加载对象。但是,当我引入块:^ {}时,restkit每次都会崩溃。
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/api/v1/places" delegate:self block:^(RKObjectLoader* loader) {
loader.objectMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[Place class]];
}];
我在日志中得到了这个:
2012-05-12 19:07:32.266 App - [RKObjectManagerloadObjectsAtResourcePath:delegate:block:]: unrecognized selector sent to instance 0x3aa2e0
2012-05-12 19:07:32.268 App - *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[RKObjectManager loadObjectsAtResourcePath:delegate:block:]: unrecognized selector sent to instance 0x3aa2e0'
有关如何解决此问题的任何想法?谢谢!
答案 0 :(得分:1)
该例外确切地告诉您问题所在:RKObjectManager
不响应loadObjectsAtResourcePath:delegate:block:
。快速浏览API文档可以发现{0}已不再存在于0.10.0中,并且似乎已被the original method替换。
您应该能够通过使用新方法来避免异常:
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/api/v1/places" usingBlock:^(RKObjectLoader* loader) {
loader.objectMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[Place class]];
}];