SwiftData, CloudKit and UIKit - Updating View When Data Changes

I have SwiftData and CloudKit working on a new version of my UIKit app. The current version uses CoreData/CloudKit I have a question. How does one know when there there is new or deleted data to update a view in a UIKit app with SwiftData? CoreData has NSPersistentStoreRemoteChangeNotificationOptionKey. What does SwiftData have that's equivalent? It's not feasible to redo my whole app to use SwiftUI at this stage.

Answered by SpaceMan in 758054022

All I had to do was observe the remote change notification within my view controller. I didn't need to turn on remote change notifications.

NotificationCenter.default.addObserver(self,
                           selector: #selector(updateView(_ :)),
                           name: .NSPersistentStoreRemoteChange,
                           object: nil)
Accepted Answer

All I had to do was observe the remote change notification within my view controller. I didn't need to turn on remote change notifications.

NotificationCenter.default.addObserver(self,
                           selector: #selector(updateView(_ :)),
                           name: .NSPersistentStoreRemoteChange,
                           object: nil)
SwiftData, CloudKit and UIKit - Updating View When Data Changes
 
 
Q