Search code examples
ioscocoa-touchnsnotifications

Where and how do I register an object for receiving a Notification?


For example, when memory gets low, the System sends a UIApplicationDidReceiveMemoryWarningNotification notification. That's all Apple says in its docs at that point. But where does this notification come from, and to which method is it sent? Or where and how do I register what that I get notified?


Solution

  • It is sent to the notification center, where all notifications are centralized. An object that wants to get informed about this notification registers itself to the notification center by telling which notification it wants to get informed and which method should be invoqued when the notification is raised.

    For more information you can take a look to Notification programming topics for Cocoa and NSNotification class reference .