---
title: "init(name:object:notificationCenter:)"
framework: xctest
role: symbol
role_heading: Initializer
path: "xctest/xctnsnotificationexpectation/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.

## Declaration

```swift
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.

## See Also

### Creating NSNotification Expectations

- [init(name:)](xctest/xctnsnotificationexpectation/init(name:).md)
- [init(name:object:)](xctest/xctnsnotificationexpectation/init(name:object:).md)
