Monday, July 30, 2012

Use Restkit Object Mapping directly

Restkit has a good object mapping library inside it. However, it's used is integrated with it's loadObject function and not really clear how we can use it directly without going through loadObject. This is useful when we have data we want to map that does not come from loadObject flow.

There's a brief hint on this on Restkit's Object Mapping manual on section Task > Performing a Mapping. It shows how the mapping is called internally.

Here's the clases related to Object Mapping in Restkit :

and here's summary of the steps :
  • create an instance of RKObjectMappingProvider
  • make mappings for each model using RKObjectMapping and add it to the instance of  RKObjectMappingProvider above (using setMapping function)
  • when it's time to do the mapping create RKObjectMapper instance following the "Performing a Mapping" documentation mentioned above




No comments: