RKResponseDescriptor vs RKRouter

So, I'm a little confused as to what the differences are between the two functions, or at least how to combine them together. I have a situation where I have this descriptor:

RKResponseDescriptor *responsePlant = [RKResponseDescriptor responseDescriptorWithMapping:plantMapping pathPattern:@"/api/rest/plants/:plant_id" keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; 

Now I would like to do something like this

 RKResponseDescriptor *responsePlantAll = [RKResponseDescriptor responseDescriptorWithMapping:plantMapping pathPattern:@"/api/rest/plants/" keyPath:@"objects" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; 

Note that keyPath is zero in one place and not in another .

It works ... but a lot of gluing copies. Can I use RKRouter for this?

Thanks a lot!

+4
source share
1 answer

You call two different paths, so using two different RKResponseDescriptor makes great sense to me!

I would also like to know if you can or should use RKRouter with RKResponseDescriptor?

I really recommend using routes. With them, all my paths are centralized in my RKObjectManager subclass, so if I need to change the path, I don't need to search everywhere!

+1
source

Source: https://habr.com/ru/post/1448020/


All Articles