RestKit 0.20忽略putObject:mapping

时间:2013-05-07 20:06:28

标签: ios mapping restkit restkit-0.20

我试图在没有映射的情况下将对象发送到服务器(PUT请求),因为我已经从服务器获得了所需的一切。即使服务器已经成功创建了对象,回调也会直接失败。

这是我正在做的一个例子:

- (void) PUTsuccess:(void (^)(RKObjectRequestOperation *operation, RKMappingResult *mappingResult))success
             failure:(void (^)(RKObjectRequestOperation *operation, NSError *error))failure
{
    RKObjectManager *objectManager = [YSManager objectManager];
    [objectManager putObject:self path:[kPutPath stringByAppendingString:self.id] parameters:kAPIDefaultParameters success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
            NSLog(@"operation.HTTPRequestOperation.request.HTTPBody: %@", [[NSString alloc] initWithData:operation.HTTPRequestOperation.request.HTTPBody encoding:NSUTF8StringEncoding]);
            if (success) {
                success(operation, mappingResult);
            }
        }
        failure:^(RKObjectRequestOperation *operation, NSError *error) {
            NSLog(@"Failure! Error: %@", error.localizedDescription);
        if (failure) {
            failure(operation, error);
        }
    }];
}

服务器响应是201创建的,我可以在服务器中找回我的对象​​,这样一切都很好,但是,回调直接触发失败,因为它试图映射我的对象,错误在失败回调中是:

Error: No response descriptors match the response loaded.

非常感谢,任何建议都将受到赞赏!

更新1 现在添加了字典映射:

RKObjectMapping *idMapping = [RKObjectMapping requestMapping];
    [idMapping addAttributeMappingsFromArray:@[]];
    RKResponseDescriptor *responseDescriptorID = [RKResponseDescriptor responseDescriptorWithMapping:idMapping
                                                                                       pathPattern:[kRequestPath stringByAppendingString:@":code"]
                                                                                           keyPath:@"objects"
                                                                                       statusCodes:statusCodes];

1 个答案:

答案 0 :(得分:1)

定义响应描述符只是为了将响应(或部分响应)映射到NSDictionary。