iOS/MacOS-iCloud警告-以SharedCodeData为基础的普遍性错误

iOS/MacOS-iCloud警告-以SharedCodeData为基础的普遍性错误,macos,ios6,icloud,Macos,Ios6,Icloud,我已尝试为自己的应用程序修改Apple SharedCodeData示例 除此警告外,一切(合理)正常: [NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:](1055): CoreData: Ubiquity: Error: A persistent store which has been previously added to a coordinator us

我已尝试为自己的应用程序修改Apple SharedCodeData示例

除此警告外,一切(合理)正常:

[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/david/Library/Containers/.../Data/Documents/SharedCoreDataStores/localStore.sqlite

This will be a fatal error in a future release.

有人遇到过这个问题吗?我该如何解决

当您看到此错误时,您正在添加包含iCloud元数据的存储文件, 表示该文件已添加到iCloud

添加iCloud存储时,应添加以下选项:

        NSDictionary *options =
        @{  NSMigratePersistentStoresAutomaticallyOption:@(YES),
        NSInferMappingModelAutomaticallyOption      :@(YES),
        NSPersistentStoreUbiquitousContentNameKey   :self.iCloudCoreDataContentName,
        NSPersistentStoreUbiquitousContentURLKey    :self.iCloudCoreDataContentURL};
self.iCloudCoreDataContentName
(require)是您想要的任何名称,一个iCloud存储,一个名称

self.iCloudCoreDataContentURL
(可选)在iCloud容器中找到核心数据传输日志

此URL应该是iCloud容器的子目录,如
[[NSFileManager URLForUbiquityContainer:nil]URLByAddingComponent:@“CoreDataLogs”]。

此属性在选项中是可选的。如果省略它,iCloud CoreData内容URL将是
[NSFileManager URL ForUbiquityContainer:nil]

有关URL和名称的更多详细信息,请注意:

如果您想将iCloud商店改为本地商店,请访问以下网址查看我的答案:

这个人也遇到过,但还没有答案:哦,天哪,我没看到那个。我通过不使用本地商店绕过了这个问题,但这不是一个好的解决方案。我必须考虑如何创建一个iCloud将参与的新店。非常感谢。代码从云端移动到本地。干得好。在您提供帮助的同时,您是否介意也看看这个问题: