Mac Developer Library

Developer

DRNotificationCenter Class Reference

Options
Deployment Target:

On This Page
Language:

DRNotificationCenter

Inheritance


Conforms To


Import Statement


Swift

import DiscRecording

Objective-C

@import DiscRecording;

Availability


Available in OS X v10.2 and later.

A DRNotificationCenter object (or simply, notification center) is essentially a notification dispatch table. It notifies all observers of notifications meeting specific criteria. This information is encapsulated in NSNotification objects, also known as notifications. Client objects register themselves with the notification center as observers of specific notifications posted by DiscRecording. When an event occurs, DiscRecording posts an appropriate notification to the notification center. The notification center dispatches a message to each registered observer, passing the notification as the sole argument.

There are two main differences between a DRNotificationCenter and the NSNotificationCenter from Foundation. First is that only Disc Recording posts notifications received through this mechanism. You use this to obtain device plug/unplug events, burn status, etc. Second, there can be multple notification centers active at once. Each run loop of your application will have it's own notification center and notifications from that notification center will be posted to the runloop it was created on.

  • Adds an observer to the receiver.

    Declaration

    Swift

    func addObserver(_ observer: AnyObject!, selector aSelector: Selector, name notificationName: String!, object anObject: AnyObject!)

    Objective-C

    - (void)addObserver:(id)observer selector:(SEL)aSelector name:(NSString *)notificationName object:(id)anObject

    Parameters

    observer

    The observer to send notifications to.

    aSelector

    The selector to call

    notificationName

    The notification to listen for

    anObject

    The object to limit notifications for.

    Discussion

    Registers anObserver to receive notifications with the name notificationName and/or containing anObject. When a notification of name notificationName containing the object anObject is posted, anObserver receives an aSelector message with this notification as the argument. The method for the selector specified in aSelector must have one and only one argument. If notificationName is nil, the notification center notifies the observer of all notifications with an object matching anObject. If anObject is nil, the notification center notifies the observer of all notifications with the name notificationName.

    The notification center does not retain anObserver or anObject. Therefore, you should always send removeObserver:name:object: to the notification center before releasing these objects.

    Import Statement

    Objective-C

    @import DiscRecording;

    Swift

    import DiscRecording

    Availability

    Available in OS X v10.2 and later.

  • Removes anObserver from receiving notifications.

    Declaration

    Swift

    func removeObserver(_ observer: AnyObject!, name aName: String!, object anObject: AnyObject!)

    Objective-C

    - (void)removeObserver:(id)observer name:(NSString *)aName object:(id)anObject

    Parameters

    observer

    The observer to remove

    aName

    The notification the remove the observer from.

    anObject

    The object the observer was listening for.

    Discussion

    Removes anObserver as the observer of notifications with the name notificationName and object anObject from the receiver. Be sure to invoke this method before deallocating the observer object or any object specified in addObserver:selector:name:object: .

    Import Statement

    Objective-C

    @import DiscRecording;

    Swift

    import DiscRecording

    Availability

    Available in OS X v10.2 and later.

  • Creates an initializes a DRNotificationCenter

    Declaration

    Swift

    class func currentRunLoopCenter() -> DRNotificationCenter!

    Objective-C

    + (DRNotificationCenter *)currentRunLoopCenter

    Return Value

    A shared DRNotificationCenter object.

    Discussion

    The instance returned sends Disc Recording notifications only to the current run loop. If you want to receive notifications on another run loop, this method must be called from that runloop.

    Import Statement

    Objective-C

    @import DiscRecording;

    Swift

    import DiscRecording

    Availability

    Available in OS X v10.2 and later.