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, or nil if the object was already deleted.

    Declaration

    Swift

    public var object: Any? { get }
  • Returns YES if the NSManagedObject instance being observed still exists, or NO if the object was already deleted.

    Declaration

    Swift

    public var isObjectDeleted: Bool { get }
  • Registers a CSObjectObserver to be notified when changes to the receiver’s object are made.

    To prevent retain-cycles, CSObjectMonitor only keeps weak 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, as CSObjectMonitor 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’s object.

    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