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

Mapping

The configuration of mapping for Core Data objects is quite similar to normal mapping configuration, though there are a few differences. First, initializing of mapping is done differently. So if we had:

RKObjectMapping *mapping = [RKObjectMapping mappingForClass:itemClass];

We need to change it to:

// Get default managed object store
RKManagedObjectStore *managedObjectStore = [RKManagedObjectStore defaultStore];

// Create mapping for entity
RKEntityMapping *mapping = [RKEntityMapping 
    mappingForEntityForName:@"Database" 
       inManagedObjectStore:managedObjectStore];

Additionally, it's a good practice to tell RestKit how to distinguish the object's uniqueness by providing identification attributes:

// How to identify if the object we got is in database ...

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