Skip to main content

FAQ

  • How do I get the library to synchronize automatically when my model gets saved?

You could call synchronizer.synchronize() right after you save your model. Alternatively, there is a ModelAdapterHasChangesNotification notification being posted when model changes are detected, so you could listen for that and trigger synchronization in response.

  • How do I detect when changes happen on another device?

SyncKit can create a CKSubscription for a given record zone so your device will receive a push notification whenever there are new changes in that record zone.


if let zoneID = synchronizer.modelAdapters.first?.recordZoneID {    synchronizer.subscribeForChanges(in: zoneID) { error in        ...    }}

Your app will also need to implement this and call synchronize in response.

optional func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)

Note that subscriptions are only possible in the private database.