Core Data Automatic Lightweight Migration
Core Data Automatic Lightweight Migration
- Subject: Core Data Automatic Lightweight Migration
- From: Richard Somers <email@hidden>
- Date: Mon, 02 Apr 2012 16:20:46 -0600
I am attempting to do a core data automatic lightweight migration. The NSPersistentDocument method -configurePersistentStoreCoordinatorForURL:... is overridden following the instructions found here http://tinyurl.com/87orsnl by Apple and here http://tinyurl.com/755zplp by Marcus Zarra.
- (BOOL)configurePersistentStoreCoordinatorForURL:(NSURL *)url ofType:(NSString *)fileType modelConfiguration:(NSString *)configuration storeOptions:(NSDictionary *)storeOptions error:(NSError **)error
{
NSMutableDictionary *options = nil;
if (storeOptions != nil) {
options = [storeOptions mutableCopy];
} else {
options = [[NSMutableDictionary alloc] init];
}
[options setObject:[NSNumber numberWithBool:YES]
forKey:NSMigratePersistentStoresAutomaticallyOption];
[options setObject:[NSNumber numberWithBool:YES]
forKey:NSInferMappingModelAutomaticallyOption];
BOOL result = [super configurePersistentStoreCoordinatorForURL:url
ofType:fileType
modelConfiguration:configuration
storeOptions:options
error:error];
[options release], options = nil;
return result;
}
The resulting behavior is somewhat bizarre.
When opening a xml document, multiple validation errors occur and the document does not open but another document "mydocument.myappxml.new" is created in the same directory as the original. The new unopened document has been correctly migrated.
When opening a sqlite document, the document opens without error but a another document "mydocument~.myappsqlite" is created in the same directory as the original.
Some developers have suggested placing Apple's options dictionary code for the persistent store coordinator in the application delegate. Refer to http://tinyurl.com/7jgknyk But this seems only to work for a specific store type. I need it to for all three store types, xml, sqlite, and binary.
Can anyone shed some light on this? Thanks.
--Richard
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden