Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 核心数据-迁移到新模型名称_Ios_Swift_Core Data Migration_Nspersistentstore_Nsmanagedobjectmodel - Fatal编程技术网

Ios 核心数据-迁移到新模型名称

Ios 核心数据-迁移到新模型名称,ios,swift,core-data-migration,nspersistentstore,nsmanagedobjectmodel,Ios,Swift,Core Data Migration,Nspersistentstore,Nsmanagedobjectmodel,现在我正在更新商店中的一个应用程序。我做了很多核心数据更改,包括更改“lazy var managedObjectModel:NSManagedObjectModel”和“lazy var persistentStoreCoordinator:NSPersistentStoreCoordinator?”中的名称 如何正确使用核心数据迁移来确保现有用户下载更新时,应用程序不会在其上崩溃 旧的: 新的: 为什么不为sqlite文件使用相同的旧名称呢?苹果公司对此有很好的文档。是的,为什么要更改文件名

现在我正在更新商店中的一个应用程序。我做了很多核心数据更改,包括更改“lazy var managedObjectModel:NSManagedObjectModel”和“lazy var persistentStoreCoordinator:NSPersistentStoreCoordinator?”中的名称

如何正确使用核心数据迁移来确保现有用户下载更新时,应用程序不会在其上崩溃

旧的:

新的:


为什么不为sqlite文件使用相同的旧名称呢?苹果公司对此有很好的文档。是的,为什么要更改文件名。是否有具体原因?请参阅此文档,我发现它对于核心数据迁移非常有用
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")