Notifications provide a mechanism for distributing information about events within an application. Notifications provide an alternative to messaging as a means for communicating between objects. Messaging requires that the sender of the message know who the receiver is when the message is dispatched. Effectively, the notifications system decouples the message sender from the message receiver. With notifications, a broadcast paradigm is implemented in which objects post notifications to a notification center , which then sends messages to objects (known as observers) which have registered their interest in the type of event, or the originating object.
The notification center is an instance of the
class; notifications are instances of the
class. Every notification object has a
name identifying the notification type, an object associated with the
notification that provides context for the notification, and an
userInfo dictionary with which posters
may pass additional information. When an observer registers with the
notification center, it specifies a method to be invoked in response
to the posting of a notification. Upon receiving a notification, the
notification center identifies the observers of the specific named
notification and invokes a predetermined method in each observer.
To obtain an instance of
the class method
. This returns an application’s default notification center. ...