NSNotification is a class used to send messages to observing classes through NSNotificationCenter.
NSNotification
is a class used to send messages to observing classes through NSNotificationCenter
. Notifications must have a name and can be optionally associated with a specific object. If an object is provided, the notification is only delivered to a class that is also observing the exact same name and object.
To send a notification, use NSNotificationCenter
's postNotification:
(a convenience function postNotificationName:object:userInfo:
also exists which creates a notification and posts it with a single call). Classes posting a notification can also include an optional userInfo
parameter to pass an object to the receiving class.
For more information, see Apple's documentation for NSNotification
and NSNotificationCenter
.