---
title: "init(name:object:)"
framework: xctest
role: symbol
role_heading: Initializer
path: "xctest/xctnsnotificationexpectation/init(name:object:)"
---

# init(name:object:)

Creates an expectation that is fulfilled when an NSNotification is posted from the default notification center by a specific object.

## Declaration

```swift
convenience init(name notificationName: NSNotification.Name, object: Any?)
```

## Parameters

- `notificationName`: The notification name to watch for.
- `object`: The object by which the notification must be posted.

## See Also

### Creating NSNotification Expectations

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