Class

NSNotificationCenter

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

Declaration

@interface NSNotificationCenter : NSObject

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 to receive notifications that passed to the provided block.

- addObserver:selector:name:object:

Adds an entry to the notification center to call the provided selector with the notification.

- removeObserver:name:object:

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

- removeObserver:

Removes all entries specifying an 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.