RestKit RKObjectMapping错误,从0.10更新到0.20

时间:2014-03-30 02:13:24

标签: ios restkit restkit-0.20

我正在将RestKit从0.10更新为0.20,并且在尝试弄清楚时会出现一些错误。

我在MappingForClass:usingBlock的Spring.m文件中遇到错误,mapKeyPathsToAttributes没有@interface,hasMany:withMapping没有@interface。

似乎无法自己解决这个问题。

Spring.h

@interface Spring : NSObject

@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSNumber *id;
@property (nonatomic, strong) NSArray *leafs;

+ (RKObjectMapping *)mapping;

@end

Spring.m

@implementation Spring

// Creating RestKit object mapping variable, THIS IS WHERE ERRORS OCCUR
+ (RKObjectMapping *)mapping {
    RKObjectMapping *objectMapping = [RKObjectMapping mappingForClass:[self class] usingBlock:^(RKObjectMapping *mapping) {
       [mapping mapKeyPathsToAttributes:
            @"name", @"name",
            @"id", @"id",
            nil];
        [mapping hasMany:@"leafs" withMapping:[Leaf mapping]];
    }];

    return objectMapping;
}

@end

我使用https://github.com/RestKit/RestKit/wiki/Upgrading-from-v0.10.x-to-v0.20.0来帮助我解决这个问题。

1 个答案:

答案 0 :(得分:0)

答案:需要使用RKRequestDescriptor