CloudKit Multi-Device Syncing

Let's suppose I want to provide a new user with some sample data which they can use to familiarize themselves with my app. In the NSPersistentContainer (i.e., local-only) case, I use one-time initialization logic to manually populate my app with this sample data. Then, over time, the user can keep that data, modify it, or delete it, as they choose.


Now if I want to do the same thing with NSPersistentCloudKitContainer, this should be fine with my user's first device. But let's further suppose that (after using my app [and changing the CoreData database contents), my user load my app on a second device and runs it. On the second device, it will ALSO build an initial database containing sample data.


What happens now? Does the content of the second device superceed the contents of the first? Suppose the user deleted a same record on device 1, but that sample record is loaded onto device 2 (as part of it's one-time initialization). Does that record reappear on device 1? And if a sample record is modified on device 1 (but appears initially unmodified on device 2), what happens? Who wins?


What is the "best practices" technique for dealing with correct synchronization of a new device (that contains sample records) with the iCloud store?

Replies

I've been reading some other posts and have the following idea. I'd appreciate any comments about whether you think this is workable:


When performing the once-only initial seeding of the Core Data store, explicitly turn off History Tracking. Once the initial records have been saved, turn it back on.


Then, the seeded values will never be synched to the cloud, but all new records and all modifications of the seeded records will. And this should occur on all devices sharing the data.


Does this sound like it will solve my problem?