<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSSpecifierTest",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSSpecifierTest"
  },
  "title" : "NSSpecifierTest"
}
-->

# NSSpecifierTest

A comparison between an object specifier and a test object.

```
class NSSpecifierTest
```

## Overview

Instances of this class represent a Boolean expression; they evaluate an object specifier and compare the resulting object to another object using a given comparison method. For more information on `NSSpecifierTest`, see the method description for its sole public method, its initializer, [`init(objectSpecifier:comparisonOperator:test:)`](/documentation/Foundation/NSSpecifierTest/init(objectSpecifier:comparisonOperator:test:)).

When an `NSSpecifierTest` object is properly initialized, it holds two objects:

- A “value” or “test” object used as the basis of the comparison; this object can be a regular object or object specifier (such as “blue” in “words whose color is blue”).
- An object specifier evaluating to the container (“words”).

The instance also encapsulates a selector identifying the method performing this comparison. The informal protocol [NSComparisonMethods](/documentation/Foundation/nscomparisonmethods) defines a set of comparison methods useful for this purpose, while <doc://com.apple.documentation/documentation/ObjectiveC/nsscriptingcomparisonmethods> describes additional methods you may need to use for scripting.

The test object is compared, using the selector, against each object in the container. Specifiers in these tests usually have [`containerIsObjectBeingTested`](/documentation/Foundation/NSScriptObjectSpecifier/containerIsObjectBeingTested) invoked on their topmost container.

You should rarely need to subclass `NSSpecifierTest`.

## Topics

### Initializing a specifier test

[`-  initWithObjectSpecifier:comparisonOperator:testObject:`](/documentation/Foundation/NSSpecifierTest/init(objectSpecifier:comparisonOperator:test:))

Returns a specifier test initialized to evaluate a test object against an object specified by an object specifier using a given comparison operation.

### Constants

[`TestComparisonOperation`](/documentation/Foundation/NSSpecifierTest/TestComparisonOperation)

These are passed to  [`init(objectSpecifier:comparisonOperator:test:)`](/documentation/Foundation/NSSpecifierTest/init(objectSpecifier:comparisonOperator:test:)) to specify the comparison operator.

## Relationships

### Conforms To

[`NSCoding`](/documentation/Foundation/NSCoding)

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

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

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

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

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

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

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

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

### Inherits From

[`NSScriptWhoseTest`](/documentation/Foundation/NSScriptWhoseTest)

---

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)