I'm building an app with Core Data and CloudKit. I need to detect when remote changes have been pushed to the app and are available in the local database to perform some work on the new data set. I've implemented .NSPersistentStoreRemoteChange
like so:
NotificationCenter.default.addObserver(self, selector: #selector(self.storeRemoteChange(_:)), name: .NSPersistentStoreRemoteChange, object: container.persistentStoreCoordinator)
The problem is this notification is received even when changes haven't been received from the remote CloudKit database, such as 4 times when the app is launched, and when a modification is made to the local database. How can I know only when changes have been received from the remote database?
userNotificationCenter(_:willPresent:withCompletionHandler:)
) are called. – Luellaluelle