Home > Back-end >  Should I use 2 PersistentContainers to allow selective Syncing?
Should I use 2 PersistentContainers to allow selective Syncing?

Time:09-30

I'm working on a Flash Card app, all flash cards should be stored in core data.

An important feature is allow some flash cards sync between devices and some not.

To sync flash cards between devices, I can use NSPersistentCloudKitContainer. But the problem is NSPersistentCloudKitContainer will sync all flash cards and I don't know if there is a way to disable syncing in some flash card.

One solution is to create 2 PersistentContaier, one with NSPersistentCloudKitContainer to store syncable flash cards and the other one is NSPersistentContainer to store non-sync flash cards.

But I'm not sure if this solution optimal is because it could add more complexity in the code later and it's hard to maintain 2 containers (?)

I would appreciate any advice

CodePudding user response:

Manage Multiple Stores section of Setting Up Core Data with CloudKit explains how to synchronize only part of data.

WWDC 2019 session – Using Core Data With CloudKit

  • Related