Class

NSNotificationCenter

A notification dispatch mechanism that enables the broadcast of information to registered observers.

Overview

Objects register with a notification center to receive notifications (NSNotification objects) using the addObserver:selector:name:object: or addObserverForName:object:queue:usingBlock: methods. Each invocation of this method specifies a set of notifications. Therefore, objects may register as observers of different notification sets by calling these methods several times.

Each running Cocoa program has a default notification center. You typically don’t create your own. An NSNotificationCenter object can deliver notifications only within a single program. If you want to post a notification to other processes or receive notifications from other processes, use an instance of NSDistributedNotificationCenter.

Topics

Getting the Notification Center

defaultCenter

Returns the process’s default notification center.

Managing Notification Observers

addObserverForName:object:queue:usingBlock:

Adds an entry to the receiver’s dispatch table with a notification queue and a block to add to the queue, and optional criteria: notification name and sender.

addObserver:selector:name:object:

Adds an entry to the receiver’s dispatch table with an observer, a notification selector and optional criteria: notification name and sender.

removeObserver:

Removes all the entries specifying a given observer from the receiver’s dispatch table.

removeObserver:name:object:

Removes matching entries from the receiver’s dispatch table.

Posting Notifications

postNotification:

Posts a given notification to the receiver.

postNotificationName:object:

Creates a notification with a given name and sender and posts it to the receiver.

postNotificationName:object:userInfo:

Creates a notification with a given name, sender, and information and posts it to the receiver.

Relationships

Inherits From

See Also

Notifications

NSNotification

A container for information broadcast through a notification center to all registered observers.

NSNotificationQueue

A notification center buffer.