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
NSManagedObjectinstance being observed, ornilif the object was already deleted.Declaration
Swift
public var object: Any? { get } -
Returns
YESif theNSManagedObjectinstance being observed still exists, orNOif the object was already deleted.Declaration
Swift
public var isObjectDeleted: Bool { get } -
Registers a
CSObjectObserverto be notified when changes to the receiver’sobjectare made.To prevent retain-cycles,
CSObjectMonitoronly keepsweakreferences 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, asCSObjectMonitorunregisters previous notifications to the observer before re-registering them.Declaration
Swift
public func addObjectObserver(_ observer: CSObjectObserver)Parameters
observeran
CSObjectObserverto send change notifications to -
Unregisters an
CSObjectObserverfrom 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
observeran
CSObjectObserverto unregister notifications to
View on GitHub
CSObjectMonitor Class Reference