One Logo Pool Ball
Foundation · IOS API REFERENCE

NotificationCenter

class · SDK 27.1

class NotificationCenter

Members (11)

get

default

TypeScript
static get default(): NotificationCenter
Swift declaration
class var `default`: NotificationCenter { get }
method · iOS 4.0+

addObserver

TypeScript
addObserver(name: (NSNotification_Name) | null, obj: (unknown) | null, queue: (OperationQueue) | null, block: ((arg0: Notification) => void)): SDKHandle
Swift declaration
func addObserver(forName name: NSNotification.Name?, object obj: Any?, queue: OperationQueue?, using block: @escaping @Sendable (Notification) -> Void) -> any NSObjectProtocol
init

init

TypeScript
static init(): NotificationCenter
Swift declaration
init()
method

post

TypeScript
post(notification: Notification): void
Swift declaration
func post(_ notification: Notification)
method

post

TypeScript
postNameObject(aName: NSNotification_Name, anObject?: (unknown) | null): void
Swift declaration
func post(name aName: NSNotification.Name, object anObject: Any?)
method

post

TypeScript
postNameObjectUserInfo(aName: NSNotification_Name, anObject?: (unknown) | null, aUserInfo?: (NativeMap<unknown, unknown>) | null): void
Swift declaration
func post(name aName: NSNotification.Name, object anObject: Any?, userInfo aUserInfo: [AnyHashable : Any]? = nil)
method

removeObserver

TypeScript
removeObserver(observer: unknown): void
Swift declaration
func removeObserver(_ observer: Any)
method

removeObserver

TypeScript
removeObserverNameObject(observer: unknown, aName?: (NSNotification_Name) | null, anObject?: (unknown) | null): void
Swift declaration
func removeObserver(_ observer: Any, name aName: NSNotification.Name?, object anObject: Any?)
method · iOS 15.0+

notifications

TypeScript
notifications(name: NSNotification_Name, object?: ((unknown) & (SDKHandle)) | null): NotificationCenter_Notifications
Swift declaration
@preconcurrency func notifications(named name: Notification.Name, object: (any AnyObject & Sendable)? = nil) -> NotificationCenter.Notifications

Returns an asynchronous sequence of notifications produced by this center for a given notification name and optional source object. - Parameters: - name: A notification name. The sequence includes only notifications with this name. - object: A source object of notifications. Specify a sender object to deliver only notifications from that sender. When `nil`, the notification center doesn't consider the sender as a criteria for delivery. - Returns: An asynchronous sequence of notifications from the center.

method · iOS 26.0+

removeObserver

TypeScript
removeObserver22175(token: NotificationCenter_ObservationToken): void
Swift declaration
func removeObserver(_ token: NotificationCenter.ObservationToken)

Stops the observation represented by the given observation token. - Parameter token: a unique token representing a specific observer in a specific notification center. You receive this type from prior calls to `addObserver(of:for:using:)`.

method · iOS 13.0+

publisher

TypeScript
publisher(name: NSNotification_Name, object?: (unknown) | null): NotificationCenter_Publisher
Swift declaration
func publisher(for name: Notification.Name, object: AnyObject? = nil) -> NotificationCenter.Publisher

Returns a publisher that emits events when broadcasting notifications. - Parameters: - name: The name of the notification to publish. - object: The object posting the named notfication. If `nil`, the publisher emits elements for any object producing a notification with the given name. - Returns: A publisher that emits events when broadcasting notifications.

Skipped declarations

14 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

NotificationCenter.addObserver(of:for:using:)

This declaration needs Swift generic type arguments. (no canonical witness for Message.Subject)

NotificationCenter.addObserver(of:for:using:)

Passing a Swift type itself is not supported.

NotificationCenter.addObserver(of:for:using:)

Passing a Swift type itself is not supported.

NotificationCenter.post(_:subject:)

This declaration needs Swift generic type arguments. (no canonical witness for Message)

NotificationCenter.post(_:)

This declaration needs Swift generic type arguments. (no canonical witness for Message)

NotificationCenter.messages(of:for:bufferSize:)

This declaration needs Swift generic type arguments. (no canonical witness for Message.Subject)

NotificationCenter.messages(of:for:bufferSize:)

Passing a Swift type itself is not supported.

NotificationCenter.messages(of:for:bufferSize:)

Passing a Swift type itself is not supported.

NotificationCenter.addObserver(of:for:using:)

This declaration needs Swift generic type arguments. (no canonical witness for Message.Subject)

NotificationCenter.addObserver(of:for:using:)

Passing a Swift type itself is not supported.

NotificationCenter.addObserver(of:for:using:)

Passing a Swift type itself is not supported.

NotificationCenter.post(_:subject:)

This declaration needs Swift generic type arguments. (no canonical witness for Message)

NotificationCenter.post(_:)

This declaration needs Swift generic type arguments. (no canonical witness for Message)

NotificationCenter.addObserver(_:selector:name:object:)

Objective-C selectors cannot cross the bridge.

All Foundation types →