2


我对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{}

有人会这么好心并给我一个正确方法的提示吗?非常感谢!

4

1 回答 1

4

查看他们关于迁移到 0.20.0的wiki 页面

该页面中与该问题相关的示例似乎是:

[ [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);
}];
于 2012-12-20T11:56:35.060 回答