我现在正在更新商店中有一个应用程序。我做了很多核心数据更改,包括更改“lazy var managedObjectModel: NSManagedObjectModel”和“lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator?”中的名称。
如何正确使用 Core Data Migration 来确保现有用户下载更新时,应用不会在他们身上崩溃?
旧:
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"MyApp-Model" withExtension:@"momd"];
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"MyApp.sqlite"];
新:
let modelURL = NSBundle.mainBundle().URLForResource("My-App", withExtension: "momd")!
let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("My-App.sqlite")