【发布时间】:2014-04-06 14:27:10
【问题描述】:
我正在尝试使用[NSPersistentStoreCoordinator removeUbiquitousContentAndPersistentStoreAtURL:options:error:] 从 iCloud 中删除核心数据。
但我得到奇怪的输出:
__93+[NSPersistentStoreCoordinator removeUbiquitousContentAndPersistentStoreAtURL:options:error:]_block_invoke(1982):
CoreData: Ubiquity: Unable to move content directory to new location:
file:///private/var/mobile/Library/Mobile%20Documents/<UBIQUITY_ID>/
New: file:///private/var/mobile/Library/Mobile%20Documents/OldUbiquitousContent-mobile~C9439AD0-1E87-4977-9C68-0674F5E2E93B
Error Domain=NSCocoaErrorDomain Code=513 "The operation couldn’t be completed.
(Cocoa error 513.)" UserInfo=0x181ab790 {NSSourceFilePathErrorKey=/private/var/mobile/Library/Mobile Documents/<UBIQUITY_ID>,
NSUserStringVariant=(
Move
), NSFilePath=/private/var/mobile/Library/Mobile Documents/<UBIQUITY_ID>,
NSDestinationFilePath=/private/var/mobile/Library/Mobile Documents/OldUbiquitousContent-mobile~C9439AD0-1E87-4977-9C68-0674F5E2E93B,
NSUnderlyingError=0x181aab50 "The operation couldn’t be completed. Operation not permitted"}
什么意思?
如何避免?我正在研究 iCloud 禁用/启用功能。详情HERE
更新:
NSDictionary *iCloudOptions =
[NSDictionary dictionaryWithObjectsAndKeys:kICloudContentNameKey, NSPersistentStoreUbiquitousContentNameKey,
iCloudURL, NSPersistentStoreUbiquitousContentURLKey, nil];
// self.lastICloudStoreURL stores NSPersistentStore.URL after stack setup
BOOL result = [NSPersistentStoreCoordinator removeUbiquitousContentAndPersistentStoreAtURL:self.lastICloudStoreURL
options:iCloudOptions
error:&error];
【问题讨论】:
-
有没有可能有一个实时持久存储协调器引用该持久存储?
-
问题解决了吗?
-
您发送哪些选项作为参数?为您的问题添加更多信息。
-
@TomHarrington,不知道如何检查。
-
@orkenstein 如果您正在使用 MagicalRecord,您应该在
removeUbiquitousContentAndPersistentStoreAtURL之前调用[MagicalRecord cleanUp];,这样您就可以确定 nothig 在删除之前保留了存储。
标签: ios objective-c core-data icloud nspersistentstore