Skip to content

Instantly share code, notes, and snippets.

@gonzalezreal
Created October 24, 2012 08:28
Show Gist options
  • Select an option

  • Save gonzalezreal/3944825 to your computer and use it in GitHub Desktop.

Select an option

Save gonzalezreal/3944825 to your computer and use it in GitHub Desktop.
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (!_persistentStoreCoordinator) {
NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
path = [path stringByAppendingPathComponent:self.account.username];
NSURL *url = [NSURL fileURLWithPath:path];
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:self.managedObjectModel];
NSError *error = nil;
[_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:url
options:nil
error:&error];
if (error) {
NSLog(@"Error creating the persistent store coordinator: %@", [error localizedDescription]);
}
}
return _persistentStoreCoordinator;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment