Reputation: 326
I am using RestKit 0.20.0rc1 in an app that uses 2 entities:
I have the following 2 response descriptors (among others):
// GET /sets/:setID/notes
// Get a set's notes. Response looks like this:
// {"notes": [ (array of NoteClass dictionaries) ],
// ...more stuff...
// }
RKResponseDescriptor *noteResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:[NoteClass rkEntityMapping]
pathPattern:@"/sets/:setID/notes"
keyPath:@"notes"
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[objectManager addResponseDescriptor:noteResponseDescriptor];
// GET /sets/:setID
// Get information about a set. Response looks like this:
// {"name": "My Set",
// "numNotes": 3,
// ...more stuff...
// }
RKResponseDescriptor *setResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:[SetClass rkEntityMapping]
pathPattern:@"/sets/:setID"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[objectManager addResponseDescriptor:setResponseDescriptor];
When I request "/sets/:setID/notes", the noteResponseDescriptor matches (expected). However, the setResponseDescriptor also matches (unexpected). I believe this is because the response descriptor's path pattern matches the substring "/sets/:setID", and because key path is nil. As a result, when I make the request, the RKMappingResult I get back contains an array of NoteClass objects (expected) and a single empty SetClass object (unexpected).
How do I prevent the setResponseDescriptor from matching this notes endpoint? I can't add a key path to the setResponseDescriptor (yet), so my preference is for a solution that allows me to say something like "match /sets/:setID$", where "$" designates the end of the URL.
Upvotes: 4
Views: 1359
Reputation: 11432
Turns out that there is now way to prevent multiple matches for your example (see the discussion here).
While a solution is on the way you have a few options for fixing this:
Each solution is flawed in it's own way though.
Upvotes: 1