我对restkit 0.20有点困惑,我知道他们添加了AFNetworking,所以他们重写了很多方法。
现在我正在寻找与objektLoaders几乎相同的方法,例如我想使用的方法:
1.
- (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObjects:(NSArray *)objects {}
2.
- (void)objectLoader:(RKObjectLoader *)objectLoader didFailWithError:(NSError *)error{}
3.
- (void)objectLoaderDidFinishLoading:(RKObjectLoader *)objectLoader{}
有人会这么善良并给我一个正确的方法吗?非常感谢!
答案 0 :(得分:4)
查看有关迁移到0.20.0的wiki page
与该问题相关的该页面的示例似乎是:
这个
[ [RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/examples" usingBlock:^(RKObjectLoader *loader) {
loader.onDidLoadObjects = ^(NSArray *objects) {
NSLog(@"It Worked: %@", objects);
};
loader.onDidFailWithError = ^(NSError *error) {
NSLog(@"It Failed: %@", error);
};
}];
变为
[RKObjectManager.sharedManager getObjectsAtPath:path parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult)
{
NSLog(@"It Worked: %@", [mappingResult array]);
// Or if you're only expecting a single object:
NSLog(@"It Worked: %@", [mappingResult firstObject]);
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"It Failed: %@", error);
}];