<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTNSNotificationExpectation/init(name:object:notificationCenter:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTNSNotificationExpectation(im)initWithName:object:notificationCenter:"
  },
  "title" : "init(name:object:notificationCenter:)"
}
-->

# init(name:object:notificationCenter:)

Creates an expectation that is fulfilled when an `NSNotification` is posted from a specific notification center, optionally by a specific object.

```
init(name notificationName: NSNotification.Name, object: Any?, notificationCenter: NotificationCenter)
```

## Parameters

`notificationName`

The notification name to watch for.

`object`

The object by which the notification must be posted, or nil if the notification can be posted by any object.

`notificationCenter`

The <doc://com.apple.documentation/documentation/Foundation/NotificationCenter> from which the notification must be posted.

## Discussion

---

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)