1

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?

simonnickel
  • 548
  • 6
  • 12
  • I could also reproduce the issue in apples demo project for NSPersistentCloudKitContainer. Instead of deleting attachments, I just removed them from the post. They still have the post assigned in iCloud Dashboard and relation got synced back on next change. – simonnickel Jun 15 '20 at 11:34
  • Not the only one with this issue btw, see: https://stackoverflow.com/questions/57470636/relationship-persistence-with-nspersistentcloudkitcontainer – simonnickel Jun 15 '20 at 11:55
  • Also posted on Apple Developer Forum: https://forums.developer.apple.com/forums/thread/649033 – simonnickel Jun 21 '20 at 09:36

0 Answers0