将Core Data Store从iCloud迁移到本地

sch*_*mok 9 migration cocoa core-data objective-c icloud

我目前正在努力应对Core Data iCloud迁移.

我想将商店从iCloud ubiquity容器(.nosync)移动到本地URL.问题是每当我打电话给这样的话:

[self.persistentStoreCoordinator migratePersistentStore: currentiCloudStore 
                                                  toURL: localURL 
                                                options: nil 
                                               withType: NSSQLiteStoreType 
                                                  error: &error];
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:](1055): CoreData: Ubiquity:  Error: A persistent store which has been previously added to a coordinator using the iCloud integration options must always be added to the coordinator with the options present in the options dictionary. If you wish to use the store without iCloud, migrate the data from the iCloud store file to a new store file in local storage. file://localhost/Users/sch/Library/Containers/bla/Data/Documents/tmp.sqlite. This will be a fatal error in a future release
Run Code Online (Sandbox Code Playgroud)

谁有人见过这个?也许我只是错过了正确的迁移选项?

小智 2

我的猜测是,根据错误消息,通过将选项设置为零,PSC 无法移动商店。您可能需要获取原始商店的选项字典并将其传递,而不是将它们设置为零。