<!--
{
  "availability" : [

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

# XCTNSPredicateExpectation

An expectation that’s fulfilled when an `NSPredicate` is satisfied.

```
class XCTNSPredicateExpectation
```

## Overview

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 the associated predicate on the main actor.

## Topics

### Creating a Predicate-Based Expectation

[`-  initWithPredicate:object:`](/documentation/XCTest/XCTNSPredicateExpectation/init(predicate:object:))

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

### Expectation Properties

[`predicate`](/documentation/XCTest/XCTNSPredicateExpectation/predicate)

The predicate the expectation evaluates.

[`object`](/documentation/XCTest/XCTNSPredicateExpectation/object)

An optional object against which the predicate evaluates.

### Handling Predicate Resolution

[`handler`](/documentation/XCTest/XCTNSPredicateExpectation/handler-swift.property)

An optional handler that performs custom evaluation when `predicate` evaluates as `true`.

[`Handler`](/documentation/XCTest/XCTNSPredicateExpectation/Handler-swift.typealias)

A handler XCTest calls when evaluating the predicate returns `true`.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`Sendable`](/documentation/Swift/Sendable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

### Inherits From

[`XCTestExpectation`](/documentation/XCTest/XCTestExpectation)

---

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)