【问题标题】:iOS Core Data + iCloud error for addPersistentStoreWithType: You don’t have permission to save the file “store” in the folder用于 addPersistentStoreWithType 的 iOS Core Data + iCloud 错误:您无权将文件“store”保存在文件夹中
【发布时间】:2016-06-11 17:59:00
【问题描述】:

我从头开始创建了一个 Core Data 项目,我所做的唯一更改是持久协调器添加存储的位置,我提供了 NSPersistentStoreUbiquitousContentNameKey 选项:

coordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: [NSPersistentStoreUbiquitousContentNameKey : "coreDataiCloudTestStore"])

我在启动时插入并保存一个新的托管对象。

在启动时没有登录 iCloud 帐户,没有问题。当应用程序运行时,我正在登录 iCloud 并返回应用程序。我收到此错误:您无权将文件“store”保存在文件夹中,不允许操作:

CoreData:错误:-addPersistentStoreWithType:SQLite 配置:PF_DEFAULT_CONFIGURATION_NAME 网址:file:///var/mobile/Containers/Data/Application/9032B2BC-BE8B-42C9-A9CC-EF3E01AA6F2B/Documents/SingleViewCoreData.sqlite 选项:{ NSPersistentStoreUbiquitousContentNameKey = coreDataiCloudTestStore; PFUbiquitySetupSynchronousSideLoadKey = 1; }

...返回错误 Error Domain=NSCocoaErrorDomain Code=513 "您无权将文件“store”保存在文件夹中 “380E290C-97F9-4DC3-9B3C-43322FCA455D”。 UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/9032B2BC-BE8B-42C9-A9CC-EF3E01AA6F2B/Documents/CoreDataUbiquitySupport/mobile~C5A2ECE3-1AB9-45FA-9C15-037DCCA054DE/coreDataiCloudTestStore/380E290C-97F9-4DC3- 9B3C-43322FCA455D/店, NSUnderlyingError=0x1453f430 {错误域=NSPOSIXErrorDomain 代码=1 “操作不允许”}} 与 userInfo 字典 { NSFilePath = "/var/mobile/Containers/Data/Application/9032B2BC-BE8B-42C9-A9CC-EF3E01AA6F2B/Documents/CoreDataUbiquitySupport/mobile~C5A2ECE3-1AB9-45FA-9C15-037DCCA054DE/coreDataiCloudTestStore/380E290C-97F9-4DC3-9B3C- 43322FCA455D/店”; NSUnderlyingError = "错误域=NSPOSIXErrorDomain Code=1 \"不允许操作\""; }

PFUbiquitySwitchboardEntry containerIdentifierChanged:: CoreData:Ubiquity:加载新的临时协调器后出错 使用选项更改帐户 { { NSPersistentStoreUbiquitousContentNameKey = coreDataiCloudTestStore; } } 和 URL file:///var/mobile/Containers/Data/Application/9032B2BC-BE8B-42C9-A9CC-EF3E01AA6F2B/Documents/SingleViewCoreData.sqlite 和错误=错误域=NSCocoaErrorDomain代码=513“你没有 在文件夹中保存文件“store”的权限 “380E290C-97F9-4DC3-9B3C-43322FCA455D”。 UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/9032B2BC-BE8B-42C9-A9CC-EF3E01AA6F2B/Documents/CoreDataUbiquitySupport/mobile~C5A2ECE3-1AB9-45FA-9C15-037DCCA054DE/coreDataiCloudTestStore/380E290C-97F9-4DC3- 9B3C-43322FCA455D/店, NSUnderlyingError=0x1453f430 {错误域=NSPOSIXErrorDomain 代码=1 "不允许操作"}}

为什么会这样?

【问题讨论】:

    标签: ios swift core-data core-data-migration ubiquity


    【解决方案1】:

    从 iCloud 重建

    要删除本地数据并使用 iCloud 中的现有记录重新开始,请在将启用 iCloud 的持久存储添加到持久存储协调器时传递值为 @YES 的 NSPersistentStoreRebuildFromUbiquitousContentOption 选项。包括您通常包括的任何 iCloud 选项。

    【讨论】:

    • 如果稍后启用 iCloud,是否有解决方案可以保留现有数据?
    猜你喜欢
    • 2018-01-08
    • 1970-01-01
    • 1970-01-01
    • 2022-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多