RKResponseDescriptor friends or foe of RKRouter?

426 views
Skip to first unread message

jervin

unread,
Dec 5, 2012, 6:06:24 PM12/5/12
to res...@googlegroups.com
Anyone know if you need or should use both RKResponseDescriptor and RKRouter together for the same object/mapping? 

So would you use both of these like this?

// Routes for Blogs

    [objectManager.router.routeSet addRoute:[RKRoute routeWithClass:[Blogs class] pathPattern:@"/blogs/:articleID" method:RKRequestMethodGET]];

    [objectManager.router.routeSet addRoute:[RKRoute routeWithClass:[Blogs class] pathPattern:@"/blogs/:articleID" method:RKRequestMethodPUT]];

    [objectManager.router.routeSet addRoute:[RKRoute routeWithClass:[Blogs class] pathPattern:@"/blogs/:articleID" method:RKRequestMethodDELETE]];

    [objectManager.router.routeSet addRoute:[RKRoute routeWithClass:[Blogs class] pathPattern:@"/blogs" method:RKRequestMethodPOST]];


RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:blogsMapping

                                                                                       pathPattern:@"/blogs/:blogID"

                                                                                           keyPath:nil

Blake Watters

unread,
Dec 5, 2012, 7:06:37 PM12/5/12
to res...@googlegroups.com
You do not have to use the router to use a response descriptor. They are completely orthogonal. You can use all of the object manager primitive methods (that don't explicitly indicate they use routes) by specifying the path directly or pass in nil and let the router do its thing.

The response descriptors are required to bind the appropriate mappings to responses.

jervin

unread,
Dec 5, 2012, 10:00:24 PM12/5/12
to res...@googlegroups.com
Ok thx!

jervin

unread,
Dec 5, 2012, 10:55:23 PM12/5/12
to res...@googlegroups.com
So using the code above when I try to use the Routes with a new object via the "object" method its says there is not "object" method?  I assume this was removed in .20? 

User *joeBlow  = [User object]
 [joeBlow setUsername:@"joeblow"];



I have to say the .20 changes are not intuitive at all. The old .9 version were very user friendly. So frustrated!

jervin

unread,
Dec 5, 2012, 11:07:07 PM12/5/12
to res...@googlegroups.com

If I use the following it half works.

User *joeBlow  = [NSEntityDescription

                                   insertNewObjectForEntityForName:@"User"

                                   inManagedObjectContext:[objectManager.managedObjectStore mainQueueManagedObjectContext] ];


But now getting all kinds of errors

Error Domain=org.restkit.RestKit.ErrorDomain Code=1001 "Unable to find any mappings for the given content" UserInfo=0x9553420 {DetailedErrors=(),
 NSLocalizedDescription=Unable to find any mappings for the given content, keyPath=null}


Are there any examples of using .20 with RKRouter? It would probably cut down on the number of posts to the forum.

Blake Watters

unread,
Dec 6, 2012, 9:52:05 AM12/6/12
to res...@googlegroups.com
I will be pushing some more full featured examples over the weekend.

Adam Chappell

unread,
Feb 21, 2013, 10:55:31 AM2/21/13
to res...@googlegroups.com
Hi Blake just wondering if you'd had a chance to post any more examples on .20 - especially with regards to how the RKRouter now works. I have to say I'm a little lost compared to .9!

Blake Watters

unread,
Feb 21, 2013, 4:19:08 PM2/21/13
to res...@googlegroups.com
Hi Adam -

I have a comprehensive guide to the entire framework in development. It's built as a guide walking through the creation of a simple app that interacts with the Gist service. I have not yet written the part about routing, but it will appear over the next few days: https://github.com/RestKit/RKGist/blob/master/TUTORIAL.md 


--
You received this message because you are subscribed to the Google Groups "RestKit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to restkit+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Adam Chappell

unread,
Feb 22, 2013, 5:05:25 AM2/22/13
to res...@googlegroups.com
OK thanks Blake, looking forward to that. 

Diego Pizzocaro

unread,
May 22, 2013, 3:15:13 PM5/22/13
to res...@googlegroups.com
Hi Blake, 
Thanks a lot for the hard work on .20.1 
As a newbie to RestKit, I really think it's an amazing framework.

Although I do have the problem highlighted in this thread. I actually cannot find much explanation on how to use RKRouter with RKResponseDescriptor in conjunction with Core Data.
Do you have any update on the docs you can push out? 

Even minimal explanation would be awesome.
Thanks again! 
Reply all
Reply to author
Forward
0 new messages