<!--
{
  "availability" : [

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

# init(predicate:object:)

Creates an expectation that’s fulfilled when an `NSPredicate` instance returns `true`, optionally for a provided object.

```
init(predicate: NSPredicate, object: Any?)
```

## Parameters

`predicate`

The predicate to evaluate.

`object`

An optional object XCTest evaluates the predicate against.

## Discussion

When you use an instance of this class from Swift and await using [`fulfillment(of:timeout:enforceOrder:)`](/documentation/XCTest/XCTestCase/fulfillment(of:timeout:enforceOrder:)) rather than [`wait(for:)`](/documentation/XCTest/XCTestCase/wait(for:)), XCTest evaluates `predicate` on the main actor.

---

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)