我最近将RestKit从0.20.3更新为0.22版。 我更新了日期格式化程序等,除了两个URL之外,一切正常。
现在我的两个POST请求找不到响应描述符。 我有一个“没有响应描述符匹配响应加载”错误列出我的RKObjectManager上的每个响应描述符。特别是以下几行:
<RKResponseDescriptor: 0x1edf4f00 baseURL=https://mybaseurl/ pathPattern=transfer/execute statusCodes=200-299> failed to match: response path 'transfer/execute' did not match the path pattern 'transfer/execute'.
有人可以引导我查看我可能错过的迁移指南吗?
如果我调试将断点放在它试图找到响应描述符的位置,然后我转到- (BOOL)gatherParameterValues:(NSArray**)pValues fromString:(NSString *)string
我得到一个YES转移/执行,所以我真的不知道它在哪里断开。
在主要方法中,RKMapperOperation上的mappingsDictionary似乎也是空的......
修改
// POST Requests
#pragma mark [POST] transfer/execute
{
// execute transfer
NSString *pathPattern = @"transfer/execute";
// route
[manager.router.routeSet
addRoute:[RKRoute routeWithClass:[Transfer class]
pathPattern:pathPattern
method:RKRequestMethodPOST]];
// request
RKMapping *requestMapping = [self.mappingProvider transferMapping];
RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor
requestDescriptorWithMapping:requestMapping
objectClass:[Transfer class]
rootKeyPath:nil
method:RKRequestMethodPOST];
[manager addRequestDescriptor:requestDescriptor];
// response
RKMapping *responseMapping = [self.mappingProvider transferResultMapping];
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor
responseDescriptorWithMapping:responseMapping
method:RKRequestMethodGET
pathPattern:pathPattern
keyPath:nil
statusCodes:statusCodesSuccess];
[manager addResponseDescriptor:responseDescriptor];
}
答案 0 :(得分:1)
您的响应描述符有method:RKRequestMethodGET
,因此在您发出POST请求时不会考虑它。将其更改为RKRequestMethodPOST
或RKRequestMethodAny
。