O'Reilly logo

RestKit for iOS by Taras Kalapun

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Advanced object mapping techniques

There might be cases when you need to make your own custom logic for a specific mapping. One of the possible ways of doing this is to define mapping to a setter, where you will process the response dictionary yourself.

For our example, as MongoDB saves the id of a document in its body. We will use such techniques to extract the id attribute from the body. First, let's look at the mapping configuration:

Class itemClass = [MDocument class];
RKObjectMapping *mapping = [RKObjectMapping 
    mappingForClass:itemClass];
[mapping addPropertyMapping:[RKAttributeMapping 
    attributeMappingFromKeyPath:nil 
                      toKeyPath:@"rootDocument"]
];

Now, rootDocument in our MDocument class is just a property with a custom setter (or you can create ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required