Before using RestKit with Core Data, be sure to check that the Core Data library is linked to your project's target and you have added #import <CoreData/CoreData.h>
before importing RestKit; for example, in the application's Prefix.pch
file:
#ifdef __OBJC__ #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import <SystemConfiguration/SystemConfiguration.h> #import <CoreData/CoreData.h> #import <RestKit/RestKit.h> #endif
The configuration of RestKit to use Core Data is quite similar if you would use Core Data without it. Create the (void)setupCoreData
method:
// Configure RestKit's Core Data stack NSURL *modelURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"MongoHq" ofType:@"momd"]]; // Due to an iOS 5 bug, the managed object model returned is immutable. NSManagedObjectModel *managedObjectModel = [[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL] mutableCopy]; RKManagedObjectStore ...