CoreData iCloud迁移“丢失”当涉及多个设备时的数据 [英] CoreData iCloud Migration "looses" data when more than one device is involved

查看:133
本文介绍了CoreData iCloud迁移“丢失”当涉及多个设备时的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近遇到了一些更新我的应用程序的主要问题。许多用户在迁移到最新版本后抱怨dataloss。



很多时候我仍然不知道发生了什么,但我有一个理论,我想确认。



迁移和iCloud



对与给定NSPersistentStoreUbiquitousContentNameKey相关联的每个模型版本,都会独立地记录和保留对商店的更改。如果模型版本匹配,则使用给定NSPersistentStoreUbiquitousContentNameKey配置的持久存储只能将数据与另一设备上的商店数据同步。



如果迁移持久存储配置为新的模型版本的NSPersistentStoreUbiquitousContentNameKey选项,来自当前设备的商店的更改历史记录也将被迁移,然后与配置了该新模型版本的任何其他设备进行合并



这意味着当我有多个设备和迁移第一个。不是源自该设备的所有数据都会丢失,因为模型版本不再匹配,直到其他设备也更新到最新版本,并且其数据和更改历史记录已迁移到新模型版本。



因为这似乎是一个风景,我可以复制的问题。这是真的吗?任何帮助和见解都赞赏...

解决方案

这几乎是正确的。如果两个设备使用不同版本的数据模型,则它们不能彼此同步。在这种情况下,数据不会丢失,但同步停止。一旦所有设备都升级,同步将恢复。



我不知道这是你的情况发生了什么,但这是那些文档想告诉你。 / p>

i recently had some major problems with an update of my app. Numerous users complained about dataloss after they migrated to the newest version.

After many hours i am still not sure what happened but i have a theory that i would like to confirm.

in the documentation Apple says:

Migration and iCloud

Changes to a store are recorded and preserved independently for each model version that is associated with a given NSPersistentStoreUbiquitousContentNameKey. A persistent store configured with a given NSPersistentStoreUbiquitousContentNameKey only syncs data with a store on another device data if the model versions match.

If you migrate a persistent store configured with a NSPersistentStoreUbiquitousContentNameKey option to a new model version, the store’s history of changes originating from the current device will also be migrated and then merged with any other devices configured with that new model version

does that mean that when i have more than one device and migrate the first. All data NOT originating from that device gets "lost" because the model versions do no longer match until the other device also updates to the newest version and its data and change history get migrated to the new model version.

Because that seems to be one scenery where i can replicate the problem. Is that really the case? any help and insights are appreciated...

解决方案

That's approximately correct. If two devices are using different versions of the data model, they can't sync with each other. Data is not "lost" in this situation, but syncing stops. Once all devices are upgraded, syncing should resume.

I don't know if that's what's happening in your case, but that's what those docs are trying to tell you.

这篇关于CoreData iCloud迁移“丢失”当涉及多个设备时的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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