Skip to content

Instantly share code, notes, and snippets.

@Rich86man
Created May 30, 2013 20:27
Show Gist options
  • Save Rich86man/5680906 to your computer and use it in GitHub Desktop.
Save Rich86man/5680906 to your computer and use it in GitHub Desktop.
persistantStoreCoordinator
// Returns the persistent store coordinator for the application.
// If the coordinator doesn't already exist, it is created and the application's store added to it.
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (!_persistentStoreCoordinator) {
NSURL *storeURL = [[[NSFileManager defaultManager] applicationDocumentsDirectory] URLByAppendingPathComponent:@"UfoSightings.sqlite"];
NSError *error = nil;
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
}
return _persistentStoreCoordinator;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment