Issue with optional Core Data relationship using NSPersistentCloudKitContainer

拥有回忆 提交于 2020-06-26 12:23:48

问题


I am using NSPersistentCloudKitContainer, not sure if that's the cause of my issue or CloudKit generic behaviour. The sync setup works fine so far. I am now adding a new feature, causing some an issue:

I have an entity Item, which can be put in a Group. Relation in CD is to-one and optional. Works fine on device: I can set and remove group, everything is persisted.

But CloudKit just ignores when I remove the group. It does not complain, just ignores it. No matter if remove happens from Item, Groups or both sides. On next download it’s back in a group. Is it just a bug in NSPersistentCloudKitContainer? It’s possible to nil fields on CloudKit records, right?

What I see in CloudKit dashboard: • Group field on Item is of type String. • A fresh Item record, never assigned to a group, does not have the group field. • As soon as it gets a group field, I can’t get rid of it. Emptying the value causes to crash.

When I get the CloudKit record on device, it does not even have the group field. So I can't manually reset it. It only shows the Group field in the CloudKit dashboard. I guess the container handles the relationship internally and only maps it during sync.

Is there any way to properly handle this?

来源:https://stackoverflow.com/questions/62000858/issue-with-optional-core-data-relationship-using-nspersistentcloudkitcontainer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!