Sunday, 5 June 2011

Core Data schema change migration

Place the below in your:

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator

To remove the old data store (clear out old data models):

[[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil];

To migrate data using Lightweight Migration

[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES],NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

In Xcode 4 we migrate data models by:
select data model. (on left)
Apple - alt - 1 ( View - Utilities - File Inspector)
Versioned Data model (on right side of utilities window)

No comments:

Post a Comment