Fixes to new store loading if not migrated.
This commit is contained in:
parent
06c62f70ed
commit
a043b7c049
@ -423,7 +423,7 @@
|
|||||||
case MPElementTypeGeneratedShort:
|
case MPElementTypeGeneratedShort:
|
||||||
case MPElementTypeGeneratedPIN:
|
case MPElementTypeGeneratedPIN:
|
||||||
case MPElementTypeGeneratedName: {
|
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;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,10 +146,17 @@ PearlAssociatedObjectProperty( NSManagedObjectContext*, MainManagedObjectContext
|
|||||||
[self migrateStore];
|
[self migrateStore];
|
||||||
|
|
||||||
// Create a new store coordinator.
|
// Create a new store coordinator.
|
||||||
|
if (!self.persistentStoreCoordinator)
|
||||||
self.persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:
|
self.persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:
|
||||||
[NSManagedObjectModel mergedModelFromBundles:nil]];
|
[NSManagedObjectModel mergedModelFromBundles:nil]];
|
||||||
NSError *error = 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:@{
|
options:@{
|
||||||
NSMigratePersistentStoresAutomaticallyOption : @YES,
|
NSMigratePersistentStoresAutomaticallyOption : @YES,
|
||||||
NSInferMappingModelAutomaticallyOption : @YES,
|
NSInferMappingModelAutomaticallyOption : @YES,
|
||||||
|
Loading…
Reference in New Issue
Block a user