【发布时间】:2016-07-15 00:15:31
【问题描述】:
我使用 RestKit 0.26 版并尝试将响应映射到核心数据
这是我用于构建请求和描述符的代码:
-(void)getProductListProductWithPageNumber: (int) pageNumber managedObjectStore: (RKManagedObjectStore *)managedObjectStore {
// initialize AFNetworking HTTPClient
NSURL *baseURL = [NSURL URLWithString:@"https://server.com"];
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client];
objectManager.managedObjectStore = managedObjectStore;
RKResponseDescriptor *productListrResponseDescriptor =
[RKResponseDescriptor responseDescriptorWithMapping:[[CategoricalSystemDownloadManager sharedDownloadManager] getCDProductListProductMapping:managedObjectStore]
method:RKRequestMethodGET
pathPattern:@"/PLController/plProducts/:"
keyPath:nil
statusCodes:[NSIndexSet indexSetWithIndex:200]];
[objectManager addResponseDescriptor:productListrResponseDescriptor];
[objectManager getObjectsAtPath:[NSString stringWithFormat:@"/PLController/plProducts/currentResponseBody-%d", pageNumber]
parameters:nil
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
}
failure:^(RKObjectRequestOperation *operation, NSError *error) {
}];
}
映射的 JSON 确实是一个数组 -> 键路径 nil,对吗? 它看起来像这样: [ { “产品ID”:240, “品牌标识”:69 } ]
这是错误
which failed to match all (0) response descriptors
【问题讨论】:
标签: objective-c restkit restkit-0.20