我为自己的 API 请求创建了某种包装类,如下所示:
+ (void)sendGETRequestWithURLString:(NSString *)request mapping:(NSString *)mapping withFailBlock:(RKRequestDidFailLoadWithErrorBlock)failBlock completion:(kServiceCompleteBlock)completion {
RKObjectManager *manager = [RKObjectManager sharedManager];
[manager loadObjectsAtResourcePath:request usingBlock:^(RKObjectLoader *loader) {
loader.onDidLoadResponse = ^(RKResponse *response) {
[self fireErrorBlock:failBlock onErrorInResponse:response];
if (completion)
completion(response);
};
}];
}
我正在尝试映射响应。当我使用 RestKit 0.9 时,我将它映射到 AppDelegate 中,如下所示:
RKObjectMapping* categoryMapping = [RKObjectMapping mappingForClass:[Category class]];
[categoryMapping mapKeyPath:@"id" toAttribute:@"categoryID"];
[categoryMapping mapKeyPath:@"name_ar" toAttribute:@"arabicName"];
[categoryMapping mapKeyPath:@"name_en" toAttribute:@"englishName"];
[categoryMapping mapKeyPath:@"img" toAttribute:@"imageUri"];
[categoryMapping mapKeyPath:@"img_en" toAttribute:@"imageEnUri"];
在 10.0 之前的代码中,我如何将上述映射连接到我的请求?