CSObjectObserver
@available(OSX 10.12, *)
@objc
public protocol CSObjectObserver : AnyObject
Implement the CSObjectObserver
protocol to observe changes to a single NSManagedObject
instance. CSObjectObserver
s 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
object
occursDeclaration
Swift
@objc optional func objectMonitor(_ monitor: CSObjectMonitor, willUpdateObject object: Any)
Parameters
monitor
the
CSObjectMonitor
monitoring the object being observedobject
the
NSManagedObject
instance being observed -
Handles processing right after a change to the observed
object
occursDeclaration
Swift
@objc optional func objectMonitor(_ monitor: CSObjectMonitor, didUpdateObject object: Any, changedPersistentKeys: Set<String>)
Parameters
monitor
the
CSObjectMonitor
monitoring the object being observedobject
the
NSManagedObject
instance being observedchangedPersistentKeys
an
NSSet
of key paths for the attributes that were changed. Note thatchangedPersistentKeys
only contains keys for attributes/relationships present in the persistent store, thus transient properties will not be reported. -
Handles processing right after
object
is deletedDeclaration
Swift
@objc optional func objectMonitor(_ monitor: CSObjectMonitor, didDeleteObject object: Any)
Parameters
monitor
the
CSObjectMonitor
monitoring the object being observedobject
the
NSManagedObject
instance being observed