Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I attempted to use my own CoreData configuration with the new version of RestKit and ended up running into several issues with objects being accessed from different contexts and data inconsistency. Here is the code for my RestKit initialization:</p> <pre><code>NSError * error; NSURL * modelURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"CoreData" ofType:@"momd"]]; NSManagedObjectModel * managedObjectModel = [[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL] mutableCopy]; RKManagedObjectStore * managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel]; [managedObjectStore createPersistentStoreCoordinator]; NSArray * searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString * documentPath = [searchPaths objectAtIndex:0]; NSPersistentStore * persistentStore = [managedObjectStore addSQLitePersistentStoreAtPath:[NSString stringWithFormat:@"%@/CoreData.sqlite", documentPath] fromSeedDatabaseAtPath:nil withConfiguration:nil options:nil error:&amp;error]; if(!persistentStore){ NSLog(@"Failed to add persistent store: %@", error); } [managedObjectStore createManagedObjectContexts]; [RKManagedObjectStore setDefaultStore:managedObjectStore]; _objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://localhost:3000/"]]; _objectManager.managedObjectStore = managedObjectStore; // Object Mapping Code... </code></pre> <p>From your context manager, you can access the generate context with <code>[RKObjectManager sharedManager].managedObjectStore.mainQueueManagedObjectContext</code> That should allow you to still make your CoreData queries with your manager.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload