ObjectObserver
@available(OSX 10.12, *)
public protocol ObjectObserver : AnyObject
Implement the ObjectObserver
protocol to observe changes to a single DynamicObject
instance. ObjectObserver
s may register themselves to a ObjectMonitor
‘s addObserver(_:)
method:
let monitor = CoreStore.monitorObject(object)
monitor.addObserver(self)
-
The
DynamicObject
type for the observed objectDeclaration
Swift
associatedtype ObjectEntityType : DynamicObject
-
objectMonitor(_:willUpdateObject:)
Default implementationHandles processing just before a change to the observed
object
occurs. (Optional) The default implementation does nothing.Default Implementation
Declaration
Swift
func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, willUpdateObject object: ObjectEntityType)
Parameters
monitor
the
ObjectMonitor
monitoring the object being observedobject
the
DynamicObject
instance being observed -
objectMonitor(_:didUpdateObject:changedPersistentKeys:)
Default implementationHandles processing right after a change to the observed
object
occurs. (Optional) The default implementation does nothing.Default Implementation
Declaration
Swift
func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didUpdateObject object: ObjectEntityType, changedPersistentKeys: Set<KeyPathString>)
Parameters
monitor
the
ObjectMonitor
monitoring the object being observedobject
the
DynamicObject
instance being observedchangedPersistentKeys
a
Set
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. -
objectMonitor(_:didDeleteObject:)
Default implementationHandles processing right after
object
is deleted. (Optional) The default implementation does nothing.Default Implementation
Declaration
Swift
func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didDeleteObject object: ObjectEntityType)
Parameters
monitor
the
ObjectMonitor
monitoring the object being observedobject
the
DynamicObject
instance being observed