In the past I have specified path parameters for every RKResponseDescriptor as well as every RKObjectManager get/post/patch/delete method. This works, but it seems like RKRouter is the better, more modular way to do this.
I'm having trouble setting up a dynamic route that contains nested variables. For example:
Adding a route
RKRoute *locationsRoute = [RKRoute routeWithClass:[Location class] pathPattern:@"users/:userID/locations/:locationID" method:RKRequestMethodAny];
[[RKObjectManager sharedManager].router.routeSet addRoutes:@[locationsRoute]];
Setting up response descriptor
RKResponseDescriptor *locationResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:locationResponseMapping
method:RKRequestMethodAny
pathPattern:nil
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
Making an object manager call
[[RKObjectManager sharedManager] getObject:[Location class] path:nil parameters:nil success:nil failure:nil];
Before using a router, I would include the userID in the object manager call path. (Like: path:[NSString stringWithFormat:@"users/%@/locations/%@", [self getCurrentUser].userID, location.locationID]
). However, when using a router, I can't seem to figure out how to specify that. What's the correct way to do this? I'm hoping the userID doesn't have to be hard coded into the route path.
It's important to note that all my mappings are set up properly, everything worked flawlessly before trying to implement routes. Any help is appreciated!
Keeping Wain's answer in mind, I ended up needing multiple different routes for a single object; the index of which is a relationship-based route. For example:
Index
Update