Name

NSDistributedNotificationCenter — Mac OS X 10.0

Synopsis

This class extends the functionality of its superclass, NSNotificationCenter, by providing a means of sending notifications to objects in other tasks. Every task has a default distributed notification center that objects send notifications to, as well as register themselves as observers. To obtain your application’s distributed notification center object, use the factory method defaultCenter.

To register an object as a receiver of a specified notification we use the method addObserver:selector:name:object:. The observer is the object that wishes to be notified of the notification identified by name:. The argument selector: specifies what method should be invoked in response to the notification. The object: parameter allows us to restrict the notifications the observer responds to those posted by the specified object. To remove an observer, invoke the method removeObserver:, which removes the observer for all notifications. To be selective about what notifications from which objects to stop observing, use the method removeObserver:name:object:.

NSNotificationCenter provides three methods for posting notifications: postNotification:, postNotificationName:object:, and postNotification-Name:object:userInfo:. Each of these methods offers different levels of control over how the notification is posted.

For more information about the notifications system, see Chapter 2.

@interface NSDistributedNotificationCenter : NSNotificationCenter ...

Get Cocoa in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.