我正在尝试将我当前的 RestKit 升级到 0.20.3,在一种情况下,我需要将结果作为字典返回,而不是映射到任何对象。
不幸的是,下面的代码导致了一个基本上为空的 RKMappingResult 对象,尽管在 RestKit 中确实存在一个正确的字典(我检查过)。
[self.objectManager addResponseDescriptor:[RKResponseDescriptor responseDescriptorWithMapping:[RKObjectMapping mappingForClass:[NSMutableDictionary class]]
method:RKRequestMethodGET
pathPattern:@"permission.json"
keyPath:nil
statusCodes:nil]];
[self loadObject:[[NSMutableDictionary alloc] init]
method:RKRequestMethodGET
path:@"permission.json"
params:nil
success:^(RKObjectRequestOperation *op, RKMappingResult *result) {
if (success)
success([result dictionary]);
}
failure:^(RKObjectRequestOperation *op, NSError *error) {
if (failure)
failure(error);
}];
加载对象调用以下内容:
RKObjectRequestOperation *const operation =
[self operationForObject:object
method:method
path:path
params:params
success:success
failure:failure];
[self.objectManager enqueueObjectRequestOperation:operation];
return operation;
谁能给我一些指导,告诉我如何说服 RestKit 还给我一本字典?