abisson
abisson

Reputation: 4425

RKResponseDescriptor vs RKRouter

So I am a bit confused as to what are the differences of these two features, or at least, how to merge them together. I have this 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 the keyPath is nil in one place, and not in the other.

This works... but it is a lot of copy pasting for nothing. Can I use RKRouter for that?

Thanks a lot!

Upvotes: 4

Views: 548

Answers (1)

allaire
allaire

Reputation: 6045

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

I also would 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 have to change a path I don't have to look everywhere!

Upvotes: 1

Related Questions