CSObjectMonitor
@available(OSX 10.12, *)
@objc
public final class CSObjectMonitor : NSObject
The CSObjectMonitor
serves as the Objective-C bridging type for ObjectMonitor<T>
.
See also
ObjectMonitor
-
Returns the
NSManagedObject
instance being observed, ornil
if the object was already deleted.Declaration
Swift
public var object: Any? { get }
-
Returns
YES
if theNSManagedObject
instance being observed still exists, orNO
if the object was already deleted.Declaration
Swift
public var isObjectDeleted: Bool { get }
-
Registers a
CSObjectObserver
to be notified when changes to the receiver’sobject
are made.To prevent retain-cycles,
CSObjectMonitor
only keepsweak
references to its observers.For thread safety, this method needs to be called from the main thread. An assertion failure will occur (on debug builds only) if called from any thread other than the main thread.
Calling
-addObjectObserver:
multiple times on the same observer is safe, asCSObjectMonitor
unregisters previous notifications to the observer before re-registering them.Declaration
Swift
public func addObjectObserver(_ observer: CSObjectObserver)
Parameters
observer
an
CSObjectObserver
to send change notifications to -
Unregisters an
CSObjectObserver
from receiving notifications for changes to the receiver’sobject
.For thread safety, this method needs to be called from the main thread. An assertion failure will occur (on debug builds only) if called from any thread other than the main thread.
Declaration
Swift
public func removeObjectObserver(_ observer: CSObjectObserver)
Parameters
observer
an
CSObjectObserver
to unregister notifications to