I'm trying to figure out how I can fetch a list of resources that are a child of another resource, but I want to request them independently of the parent resource. I have 2 classes: User
and Notification
. When I request a user object, it does not return a list of notifications, but at a later point I would like to fetch these notifications. For this, I want to use the URL
/users/:user_id/notifications
I've setup a route defined as
RKRoute *notificationsAll = [RKRoute routeWithClass:[Notification class] pathPattern:@"users/:userID/notifications" method:RKRequestMethodAny];
But how can I request this successfully. Obviously the router needs to be aware of the userID but I'm not sure how I can supply this. Previously I have set a transient property within an object, but in this case, I don't have an object to set a transient property so that doesn't work.
I assume I'm doing something completely wrong but any help would be great
For your router to work you need to make a request using a Notification
instance and the Notification
class needs to have a property called userID
that the route can extract to inject into the path pattern.
If Notification
doesn't fit this role then you need to change the class associated with the route to one that does. That could be a dictionary or a custom object.