Is there a way to define 2 or more response descriptors all having the same pathPattern? My assumption was that they would match not only based on the pathPattern, but also on the method. But apparently that isn't the case.
Here is my object mapping:
RKObjectMapping *commentMapping = [RKObjectMapping mappingForClass:[Comment class]];
[commentMapping addAttributeMappingsFromArray:@[@"comment", @"rating", @"views", @"venue", @"user_views"]];
When I do a GET request, I get a list similar to this:
{
'meta': {
'total_objects': 2,
'limit': 20,
...
},
'objects': [
{
'comment': '...',
'rating': 3.5,
...
},
...
]
}
And when I do a POST request to create a new object, I just get back something like this:
{
'comment': '...',
'rating': 3.5,
...
}
So what I want to do is define two different responseDescriptors -- one for each request method. So this is what I did:
[objectManager addResponseDescriptor:[RKResponseDescriptor responseDescriptorWithMapping:commentMapping
method:RKRequestMethodGET
pathPattern:@"comment/"
keyPath:@"objects"
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]];
[objectManager addResponseDescriptor:[RKResponseDescriptor responseDescriptorWithMapping:commentMapping
method:RKRequestMethodPOST
pathPattern:@"comment/"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]];
The problem is, the second one (the one with a nil keyPath) is always used. Even for GET requests. Which really messes things up.
What am I doing wrong? Or is there even any way to do what I want here?