Core Data - Migrating to new Model Name

87 views Asked by At

I have an app in the store now that I am updating. I did a lot of Core Data changes, including changing the name in both 'lazy var managedObjectModel: NSManagedObjectModel' and 'lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator?'.

How can I properly use Core Data Migration to ensure when an existing user downloads the update, the app doesn't crash on them?

Old:

NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"MyApp-Model" withExtension:@"momd"];

NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"MyApp.sqlite"];

New:

let modelURL = NSBundle.mainBundle().URLForResource("My-App", withExtension: "momd")!

let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("My-App.sqlite")
0

There are 0 answers