This seems to work:
NotificationCenter.default.notifications(named: Notification.Name.NSManagedObjectContextDidSave)
Post
Replies
Boosts
Views
Activity
This works even better:
NotificationCenter.default.notifications(named: Notification.Name.NSManagedObjectContextObjectsDidChange)
Looks like a bug needs filed here. Appears that the NSManagedObjectContextObjectsDidChange is likely what ModelContext.didSave should be triggering, as the object in the notification is the ModelContext instance:
(lldb) po notif
▿ name = NSObjectsChangedInManagingContextNotification, object = Optional(SwiftData.ModelContext), userInfo = Optional([AnyHashable("updated"): Set([SwiftData.ModelContext.AnyPersistentObject(boxed: Redacted.Redacted)])])
- name : "NSObjectsChangedInManagingContextNotification"
▿ object : <ModelContext: 0x281632e50>
▿ userInfo : 1 element
▿ 0 : 2 elements
▿ key : AnyHashable("updated")
- value : "updated"
▿ value : 1 element
▿ 0 : AnyPersistentObject
▿ boxed : <Redacted: 0x280e545a0>