我想發送一個對象到服務器(PUT請求)沒有映射,因爲我已經有了我需要從服務器的一切。即使服務器已成功創建對象,回調也會直接失敗。RestKit 0.20忽略putObject:映射
下面是我在做什麼的例子:
- (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];
嘗試使用keyPath:nil並仔細檢查pathPattern。 – Roger 2013-05-07 23:49:05