/**
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_ != nil) {
return persistentStoreCoordinator_;
}
NSURL *storeURL = [[self applicationdocumentsdirectory] URLByAppendingPathComponent:@"golf.sqlite"];
NSError *error = nil;
persistentStoreCoordinator_ = [[nspersistentstorecoordinator alloc] initWithManagedObjectModel:[self managedobjectmodel]];
NSDictionary *options = [nsdictionary dictionarywithobjectsandkeys:
[nsnumber numberwithbool:yes], NSMigratePersistentStoresAutomaticallyOption,
[nsnumber numberwithbool:yes], NSInferMappingModelAutomaticallyOption, nil];
if (![persistentstorecoordinator_ addpersistentstorewithtype:nssqlitestoretype
configuration:nil
url:storeurl
options:options
error:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userinfo]);
abort();
}
return persistentStoreCoordinator_;
}