使用Core Data和iCloud时出现PFUbiquity错误 [英] PFUbiquity error when using Core Data and iCloud

查看:280
本文介绍了使用Core Data和iCloud时出现PFUbiquity错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用iCloud同步我的Core Data存储。这工作正常。我只是注意到,当我启动应用程序,我得到以下错误信息。这是正常吗?



  2014-12-06 10:06:37.337  -  [PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](808):CoreData:Ubiquity:nobody〜sim352B6DF3-0975-5C4B-B561-086A3032D6EA:ContentKeyName 
使用本地存储:1
2014-12-06 10:06:37.382 __60- [PFUbiquitySetupAssistant canReadFromUbiquityRootLocation:] _ block_invoke682(1476):CoreData:Ubiquity:试图下载对等体下载一个严重的错误为同行下载Error Domain = BRCloudDocsErrorDomain Code = 5操作couldn' (BRCloudDocsErrorDomain错误5 - 没有文档在URL)UserInfo = 0x7ff77ac9b110 {NSDescription =没有文档在URL,NSFilePath = / Users / dev / Library / Developer / CoreSimulator / Devices / 0AC7A779-9C6C-4A6C-91C5-D1973CE278D9 / data / Library / Mobile Documents / iCloud〜app〜container / Data / .DS_Store,NSUnderlyingError = 0x7ff77ac990d0操作无法完成,没有这样的文件或目录} with userInfo {
NSDescription =No document在URL;
NSFilePath =/ Users / dev / Library / Developer / CoreSimulator / Devices / 0AC7A779-9C6C-4A6C-91C5-D1973CE278D9 / data / Library / Mobile Documents / iCloud〜app〜container / Data / .DS_Store;
NSUnderlyingError =错误域= NSPOSIXErrorDomain代码= 2 \操作无法完成。没有这样的文件或目录\UserInfo = 0x7ff77ac9bee0 {NSDescription =没有这样的文件或目录};
}
2014-12-06 10:06:37.409 - [PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](808):CoreData:Ubiquity:nobody〜sim352B6DF3-0975-5C4B-B561-086A3032D6EA:ContentKeyName
使用本地存储:0


解决方案

我相信是什么问题。



当您的本地Core Data资源与iCloud同步时,在其他设备上删除的任何行都将被删除。



在内存中,您可能持有ManagedObjects,它们直接表示已删除的行,或者可能与这些行相关。



因此,当您访问这些行的属性时,故障进程期望查找Core Data行,但不会。不一致会导致错误。



我的解决方案:每当您收到NSPersistentStoreCoordinatorStoresDidChangeNotification或NSPersistentStoreDidImportUbiquitousContentChangesNotification时,刷新所有ManagedObject子类对象



希望,别人也可以从中获益。


I am using iCloud to sync my Core Data store. This works fine. I just noticed that when I launch the app I get the following error message. Is this normal? Is there something I can do to prevent it?

Thanks

2014-12-06 10:06:37.337 -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](808): CoreData: Ubiquity:  nobody~sim352B6DF3-0975-5C4B-B561-086A3032D6EA:ContentKeyName
Using local storage: 1
2014-12-06 10:06:37.382 __60-[PFUbiquitySetupAssistant canReadFromUbiquityRootLocation:]_block_invoke682(1476): CoreData: Ubiquity:  Attempting to download Peers hit a serious error for peers to download Error Domain=BRCloudDocsErrorDomain Code=5 "The operation couldn’t be completed. (BRCloudDocsErrorDomain error 5 - No document at URL)" UserInfo=0x7ff77ac9b110 {NSDescription=No document at URL, NSFilePath=/Users/dev/Library/Developer/CoreSimulator/Devices/0AC7A779-9C6C-4A6C-91C5-D1973CE278D9/data/Library/Mobile Documents/iCloud~app~container/Data/.DS_Store, NSUnderlyingError=0x7ff77ac990d0 "The operation couldn’t be completed. No such file or directory"} with userInfo {
    NSDescription = "No document at URL";
    NSFilePath = "/Users/dev/Library/Developer/CoreSimulator/Devices/0AC7A779-9C6C-4A6C-91C5-D1973CE278D9/data/Library/Mobile Documents/iCloud~app~container/Data/.DS_Store";
    NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\" UserInfo=0x7ff77ac9bee0 {NSDescription=No such file or directory}";
}
2014-12-06 10:06:37.409 -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](808): CoreData: Ubiquity:  nobody~sim352B6DF3-0975-5C4B-B561-086A3032D6EA:ContentKeyName
Using local storage: 0

解决方案

Based on my testing, here's what I believe is the problem.

When your local Core Data resources sync with iCloud, any rows deleted on another device are deleted. More rows can be deleted through the de-dupe process.

In memory you may be holding ManagedObjects which represent deleted rows directly, or may be related to those rows.

So, when you access the properties of those rows, the fault process expects to find Core Data rows, but it doesn't. The inconsistency causes the error.

My solution: Refresh all ManagedObject subclassed objects whenever you receive a NSPersistentStoreCoordinatorStoresDidChangeNotification or NSPersistentStoreDidImportUbiquitousContentChangesNotification

This worked for me. Hopefully, someone else can profit from this too.

这篇关于使用Core Data和iCloud时出现PFUbiquity错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆