How NSPersistentCloudKitContainer works in this project
mainThis project uses NSPersistentCloudKitContainer to mirror a local Core Data store to a user's private CloudKit database.
Core Components
- Model: The
CoreDataSyncmodel defines aContactentity with aname(String) and aphoto(UIImageTransformable). - Stack: The
PersistenceControllerclass initializes theNSPersistentCloudKitContainerusing theCoreDataSyncmodel. - UI Integration: The SwiftUI interface uses the
@FetchRequestproperty wrapper to observe and displayContactobjects from the local store. - Sync Mechanism: Local changes (additions or deletions via
NSManagedObjectContext) are automatically sent to the remote CloudKit private database. Remote changes are fetched via background push notifications and merged into the local store.