CSObjectObserver
@available(OSX 10.12, *)
@objc
public protocol CSObjectObserver : AnyObject
Implement the CSObjectObserver protocol to observe changes to a single NSManagedObject instance. CSObjectObservers may register themselves to a CSObjectMonitor‘s -addObjectObserver: method:
CSObjectMonitor *monitor = [CSCoreStore monitorObject:myObject];
[monitor addObjectObserver:self];
See also
ObjectObserver
-
Handles processing just before a change to the observed
objectoccursDeclaration
Swift
@objc optional func objectMonitor(_ monitor: CSObjectMonitor, willUpdateObject object: Any)Parameters
monitorthe
CSObjectMonitormonitoring the object being observedobjectthe
NSManagedObjectinstance being observed -
Handles processing right after a change to the observed
objectoccursDeclaration
Swift
@objc optional func objectMonitor(_ monitor: CSObjectMonitor, didUpdateObject object: Any, changedPersistentKeys: Set<String>)Parameters
monitorthe
CSObjectMonitormonitoring the object being observedobjectthe
NSManagedObjectinstance being observedchangedPersistentKeysan
NSSetof key paths for the attributes that were changed. Note thatchangedPersistentKeysonly contains keys for attributes/relationships present in the persistent store, thus transient properties will not be reported. -
Handles processing right after
objectis deletedDeclaration
Swift
@objc optional func objectMonitor(_ monitor: CSObjectMonitor, didDeleteObject object: Any)Parameters
monitorthe
CSObjectMonitormonitoring the object being observedobjectthe
NSManagedObjectinstance being observed
View on GitHub
CSObjectObserver Protocol Reference