NSNotificationCenter allows to send and register for notifications in the Foundation framework, which is provided by Apple.
An NSNotificationCenter
object (or simply, notification center) provides a mechanism for broadcasting information within a program. An NSNotificationCenter
object is essentially a notification dispatch table. Notifications are differentiated according to their name and contain an object (the sender) as well as any specific data.
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.
You can also post notifications with postNotification:
, or create and post notifications with postNotificationName:object:
and postNotificationName:object:userInfo:
, where you may use custom names for your notifications.