<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSComparisonPredicate",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSComparisonPredicate"
  },
  "title" : "NSComparisonPredicate"
}
-->

# NSComparisonPredicate

A specialized predicate for comparing expressions.

```
class NSComparisonPredicate
```

## Overview

Use comparison predicates to compare the results of two expressions. You create a comparison predicate with an operator, a left expression, and a right expression, and use instances of the [`NSExpression`](/documentation/Foundation/NSExpression) class to represent those expressions. When you evaluate the predicate, it returns a `BOOL` value as the result of invoking the operator with the results of evaluating the expressions.

## Topics

### Creating Comparison Predicates

  <doc://com.apple.documentation/documentation/UIKit/displaying-searchable-content-by-using-a-search-controller>

[`+  predicateWithLeftExpression:rightExpression:customSelector:`](/documentation/Foundation/NSComparisonPredicate/predicateWithLeftExpression:rightExpression:customSelector:)

Returns a new predicate formed by combining the left and right expressions using a given selector.

[`+  predicateWithLeftExpression:rightExpression:modifier:type:options:`](/documentation/Foundation/NSComparisonPredicate/predicateWithLeftExpression:rightExpression:modifier:type:options:)

Creates and returns a predicate of a given type formed by combining given left and right expressions using a given modifier and options.

[`-  initWithLeftExpression:rightExpression:customSelector:`](/documentation/Foundation/NSComparisonPredicate/init(leftExpression:rightExpression:customSelector:))

Creates a predicate that you form by combining specified left and right expressions using a specified selector.

[`-  initWithLeftExpression:rightExpression:modifier:type:options:`](/documentation/Foundation/NSComparisonPredicate/init(leftExpression:rightExpression:modifier:type:options:))

Creates a predicate to a specified type that you form by combining specified left and right expressions using a specified modifier and options.

[`-  initWithCoder:`](/documentation/Foundation/NSComparisonPredicate/init(coder:))

Creates a predicate by decoding from the coder you specify.

### Getting Information About a Comparison Predicate

[`comparisonPredicateModifier`](/documentation/Foundation/NSComparisonPredicate/comparisonPredicateModifier)

The comparison predicate modifier for the receiver.

[`Modifier`](/documentation/Foundation/NSComparisonPredicate/Modifier)

Constants that describe the possible types of modifier for a comparison predicate.

[`customSelector`](/documentation/Foundation/NSComparisonPredicate/customSelector)

The selector for the receiver.

[`rightExpression`](/documentation/Foundation/NSComparisonPredicate/rightExpression)

The right expression for the receiver.

[`leftExpression`](/documentation/Foundation/NSComparisonPredicate/leftExpression)

The left expression for the receiver.

[`options`](/documentation/Foundation/NSComparisonPredicate/options-swift.property)

The options to use for the receiver.

[`Options`](/documentation/Foundation/NSComparisonPredicate/Options-swift.struct)

Constants that describe the possible types of string comparison for comparison predicates.

[`predicateOperatorType`](/documentation/Foundation/NSComparisonPredicate/predicateOperatorType)

The predicate type for the receiver.

[`Operator`](/documentation/Foundation/NSComparisonPredicate/Operator)

Defines the type of comparison for a comparison predicate.

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

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

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

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

### Inherits From

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

---

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)