A notification dispatch mechanism that enables the broadcast of information to registered observers.
SDKs
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
class NotificationCenter : NSObject
Overview
Objects register with a notification center to receive notifications (NSNotification
objects) using the add
or add
methods. When an object adds itself as an observer, it specifies which notifications it should receive. An object may therefore call this method several times in order to register itself as an observer for several different notifications.
Each running app has a default
notification center, and you can create new notification centers to organize communications in particular contexts.
A notification center 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 Distributed
instead.