我正在尝试创建一个RKResponseDescriptor来让人们进入会话。
我有/ sessions的响应描述符,但我不知道如何创建它来让人们进入sessions / sessions / 20 / people(/ sessions / sessionID / people)。
我的会话响应描述符是;
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:sessionsMapping
pathPattern:@"/sessions"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
会话中人员的响应描述符是;
RKResponseDescriptor *clientInSessionResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:clientsInSessionMapping
pathPattern:@"/sessions/:sessionID/people"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
我一直收到错误,“因错误而失败:没有响应描述符与加载的响应匹配。”
我注意到在文档中有很多用法:id但似乎无法弄明白。另外,我应该使用RKPathMatcher来构建路径吗?
非常感谢任何帮助。
答案 0 :(得分:0)
我在发送请求路径时所做的是参数替换。所以在你的情况下我会做以下事情:
NSString *idValue; // this is the sessionID value
NSString *path = [@"/sessions/:sessionID/people" stringByReplacingOccurrencesOfString:@":sessionID" withString:idValue];
[[RKObjectManager sharedManager] getObjectsAtPath:path parameters:nil success:^(RKObjectRequestOperation *operation,RKMappingResult *mappingResult)
{
// handle success
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
RKLogError(@"*** RK load FAIL");
}]