0

I have to use different request descriptors for the same class (for different HTTP methods).

Use case is the following:

I have User class with some attributes (properties), for example, identity, username, password, firstname, lastname.

I want to use request descriptor for POST method, which uses all these fields, and another request descriptor for PUT method, which handles only firstname, lastname and password. (In this example, I don't want to modify identity and username).

How can I do this?

Thanks!

Oxygen
  • 11
  • 1

1 Answers1

0

I have a similar problem - essentially wanting to cherry-pick fields from a managed object to POST back to the server. The fields I want depend on the service endpoint. I suspect subclassing the ObjectManager is probably the neatest way to go. Pragmatism wins for me today, however, and in my (client-side) web service API access class I add the descriptors (with end-point-specific object mappings) before making a request, and then remove them again afterwards, leaving my ObjectManager shiny and clean.

The RKObjectManager class documentation has a section on customization and subclassing: http://restkit.org/api/latest/Classes/RKObjectManager.html#tasks

Robin Macharg
  • 1,468
  • 14
  • 22