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. When an object adds itself as an observer, it specifies which notifications it should receive. An object may therefore call this method several times in order to register itself as an observer for several different notifications.

Each running app has a defaultCenter notification center, and you can create new notification centers to organize communications in particular contexts.

A notification center 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 NSDistributedNotificationCenter instead.

Topics

Getting the Default Notification Center

defaultCenter

The app’s default notification center.

Adding and Removing Notification Observers

addObserverForName:object:queue:usingBlock:

Adds an entry to the notification center's dispatch table that includes a notification queue and a block to add to the queue, and an optional notification name and sender.

addObserver:selector:name:object:

Adds an entry to the notification center's dispatch table with an observer and a notification selector, and an optional notification name and sender.

removeObserver:name:object:

Removes matching entries from the notification center's dispatch table.

removeObserver:

Removes all entries specifying a given observer from the notification center's dispatch table.

Posting Notifications

postNotification:

Posts a given notification to the notification center.

postNotificationName:object:userInfo:

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

postNotificationName:object:

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

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.