Class

NSNotification​Center

An NSNotification​Center object (or simply, notification center) provides a mechanism for broadcasting information within a program. An NSNotification​Center object is essentially a notification dispatch table.

Overview

Objects register with a notification center to receive notifications (NSNotification objects) using the add​Observer:​selector:​name:​object:​ or add​Observer​For​Name:​object:​queue:​using​Block:​ 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 NSNotification​Center 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 NSDistributed​Notification​Center.

Symbols

Getting the Notification Center

default​Center

Returns the process’s default notification center.

Managing Notification Observers

- add​Observer​For​Name:​​object:​​queue:​​using​Block:​​

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.

- add​Observer:​​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.

- remove​Observer:​​

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

- remove​Observer:​​name:​​object:​​

Removes matching entries from the receiver’s dispatch table.

Posting Notifications

- post​Notification:​​

Posts a given notification to the receiver.

- post​Notification​Name:​​object:​​

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

- post​Notification​Name:​​object:​​user​Info:​​

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

Relationships

Inherits From