2

I am trying to create a RKResponseDescriptor to get people in a session.

I have a response descriptor for /sessions but I don't know how to create it to get the people in the sessions /sessions/20/people (/sessions/sessionID/people).

My session response descriptor is;

RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:sessionsMapping
                                                                                   pathPattern:@"/sessions"
                                                                                       keyPath:nil
                                                                                   statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

The response descriptor for the people in the session is;

RKResponseDescriptor *clientInSessionResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:clientsInSessionMapping
                                                                                   pathPattern:@"/sessions/:sessionID/people"
                                                                                       keyPath:nil
                                                                                   statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

I keep getting the error, "Failed with error: No response descriptors match the response loaded."

I noticed in the documentation there is a lot of usage of the :id but can't seem to figure it out. Also, should I use a RKPathMatcher to build the path?

Any help would be greatly appreciated.

4

1 回答 1

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");
}]
于 2013-03-08T20:01:00.067 回答