Fixes to new store loading if not migrated.
This commit is contained in:
parent
06c62f70ed
commit
a043b7c049
@ -423,7 +423,7 @@
|
||||
case MPElementTypeGeneratedShort:
|
||||
case MPElementTypeGeneratedPIN:
|
||||
case MPElementTypeGeneratedName: {
|
||||
NSAssert( NO, @"Cannot save content to element with generated type %lu.", (long)element.type );
|
||||
wrn( @"Cannot save content to element with generated type %lu.", (long)element.type );
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -146,10 +146,17 @@ PearlAssociatedObjectProperty( NSManagedObjectContext*, MainManagedObjectContext
|
||||
[self migrateStore];
|
||||
|
||||
// Create a new store coordinator.
|
||||
if (!self.persistentStoreCoordinator)
|
||||
self.persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:
|
||||
[NSManagedObjectModel mergedModelFromBundles:nil]];
|
||||
NSError *error = nil;
|
||||
[self.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:[self localStoreURL]
|
||||
NSURL *localStoreURL = [self localStoreURL];
|
||||
if (![[NSFileManager defaultManager] createDirectoryAtURL:[localStoreURL URLByDeletingLastPathComponent]
|
||||
withIntermediateDirectories:YES attributes:nil error:&error]) {
|
||||
err( @"Couldn't create our application support directory: %@", [error fullDescription] );
|
||||
return;
|
||||
}
|
||||
[self.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:localStoreURL
|
||||
options:@{
|
||||
NSMigratePersistentStoresAutomaticallyOption : @YES,
|
||||
NSInferMappingModelAutomaticallyOption : @YES,
|
||||
|
Loading…
Reference in New Issue
Block a user