<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NotificationCenter/notifications(named:object:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:So20NSNotificationCenterC10FoundationE13notifications5named6objectAbCE13NotificationsCSo0A4Namea_yXlSgtF"
  },
  "title" : "notifications(named:object:)"
}
-->

# notifications(named:object:)

Returns an asynchronous sequence of notifications produced by this center for a given notification name and optional source object.

```
@preconcurrency func notifications(named name: Notification.Name, object: (any AnyObject & Sendable)? = nil) -> NotificationCenter.Notifications
```

## 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.

## Return Value

An asynchronous sequence of notifications from the center.

## Discussion

Use this method to receive notifications from the center as an <doc://com.apple.documentation/documentation/Swift/AsyncSequence>. You iterate over this sequence with `for`-`await`-`in` syntax.

[`Notification`](/documentation/Foundation/Notification) doesn’t conform to <doc://com.apple.documentation/documentation/Swift/Sendable>, because several of its members can’t be sendable, such as [`object`](/documentation/Foundation/Notification/object) and the [`userInfo`](/documentation/Foundation/Notification/userInfo) dictionary. If you iterate over the notifications in this sequence, Xcode issues a warning about crossing an actor boundary. To handle this, use a `NotificationCenter/Notifications/map(_:)-3wc5j` or `NotificationCenter/Notifications/compactMap(_:)-6wlbd` to extract sendable properties of the notification, such as its [`name`](/documentation/Foundation/Notification/name-swift.property) or sendable values from the [`userInfo`](/documentation/Foundation/Notification/userInfo) dictionary.

The following macOS example calls [`notifications(named:object:)`](/documentation/Foundation/NotificationCenter/notifications(named:object:)) to receive an asynchronous sequence of <doc://com.apple.documentation/documentation/AppKit/NSWorkspace/didActivateApplicationNotification> notifications from the shared <doc://com.apple.documentation/documentation/AppKit/NSWorkspace> notification center. It then uses a `NotificationCenter/Notifications/compactMap(_:)-6wlbd` to retrieve <doc://com.apple.documentation/documentation/AppKit/NSRunningApplication> values from the notification’s [`userInfo`](/documentation/Foundation/Notification/userInfo) dictionary, from which it gets <doc://com.apple.documentation/documentation/AppKit/NSRunningApplication/localizedName> strings. Since the <doc://com.apple.documentation/documentation/Swift/String> type conforms to <doc://com.apple.documentation/documentation/Swift/Sendable>, you can iterate over this type without a compiler warning.

```swift
for await appName in NSWorkspace.shared.notificationCenter.notifications (
    named: NSWorkspace.didActivateApplicationNotification)
    .compactMap ({ notification in
        guard let appInfo = notification.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication,
              let name = appInfo.localizedName else { return nil as String? }
        return name
    })
{
    print("Application activated: \(appName)")
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)