---
title: NotificationCenter
framework: foundation
role: symbol
role_heading: Class
path: foundation/notificationcenter
---

# NotificationCenter

A notification dispatch mechanism that enables the broadcast of information to registered observers.

## Declaration

```swift
class NotificationCenter
```

## Overview

Overview Callers register with a notification center to receive one or both of the following: NSNotification objects, when working in Objective-C or with frameworks that only support NSNotification. Objects register with a notification center to receive notifications (NSNotification objects) using the addObserver(_:selector:name:object:) or addObserver(forName:object:queue:using:) methods, specifying a notification name and optionally a source object. When a caller adds itself as an observer, it specifies which notifications it should receive. NotificationCenter.MainActorMessage and NotificationCenter.AsyncMessage instances for use with Swift code, providing strong typing, appropriate actor isolation, and a more idiomatic Swift experience. Callers register with the notification center using the various flavors of the addObserver(of:for:using:) method, specifying either a message type or a convenience NotificationCenter.MessageIdentifier to identify the notification messages to receive. See Notification center messages for more information about this API. Callers may add observers for many different notifications, or even the same notification name or message type as produced by different source objects. 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. On macOS, if you want to post a notification to other processes or receive notifications from other processes, use DistributedNotificationCenter instead.

## Topics

### Getting the default notification center

- [default](foundation/notificationcenter/default.md)

### Adding and removing notification observers

- [addObserver(forName:object:queue:using:)](foundation/notificationcenter/addobserver(forname:object:queue:using:).md)
- [addObserver(_:selector:name:object:)](foundation/notificationcenter/addobserver(_:selector:name:object:).md)
- [removeObserver(_:name:object:)](foundation/notificationcenter/removeobserver(_:name:object:).md)
- [removeObserver(_:)](foundation/notificationcenter/removeobserver(_:)-2yciv.md)

### Posting notifications

- [post(_:)](foundation/notificationcenter/post(_:)-3x2st.md)
- [post(name:object:userInfo:)](foundation/notificationcenter/post(name:object:userinfo:).md)
- [post(name:object:)](foundation/notificationcenter/post(name:object:).md)

### Receiving notifications as an asynchronous sequence

- [notifications(named:object:)](foundation/notificationcenter/notifications(named:object:).md)
- [NotificationCenter.Notifications](foundation/notificationcenter/notifications.md)

### Receiving notifications as a Combine publisher

- [publisher(for:object:)](foundation/notificationcenter/publisher(for:object:).md)
- [NotificationCenter.Publisher](foundation/notificationcenter/publisher.md)

### Using notification center with Swift actor isolation

- [Notification center messages](foundation/notification-center-messages.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [DistributedNotificationCenter](foundation/distributednotificationcenter.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Notifications

- [Notification](foundation/notification.md)
- [NotificationQueue](foundation/notificationqueue.md)
