Class

NSCompoundPredicate

NSCompoundPredicate is a subclass of NSPredicate used to represent logical “gate” operations (AND/OR/NOT) and comparison operations.

Overview

Comparison operations are based on two expressions, as represented by instances of the NSExpression class. Expressions are created for constant values, key paths, and so on.

In macOS 10.5 and later and in iOS, you can use NSCompoundPredicate to create an AND or OR compound predicate (but not a NOT compound predicate) using an array with 0, 1, or more elements:

  • An AND predicate with no subpredicates evaluates to TRUE.

  • An OR predicate with no subpredicates evaluates to FALSE.

  • A compound predicate with one or more subpredicates evaluates to the truth of its subpredicates.

Nested Types

NSCompoundPredicateType

These constants describe the possible types of NSCompoundPredicate.

Symbols

Constructors

init(andPredicateWithSubpredicates: [NSPredicate])

Returns a new predicate formed by AND-ing the predicates in a given array.

init(notPredicateWithSubpredicate: NSPredicate)

Returns a new predicate formed by NOT-ing a given predicate.

init(orPredicateWithSubpredicates: [NSPredicate])

Returns a new predicate formed by OR-ing the predicates in a given array.

init(type: NSCompoundPredicate.LogicalType, subpredicates: [NSPredicate])

Returns the receiver initialized to a given type using predicates from a given array.

Getting Information About a Compound Predicate

var subpredicates: [Any]

The receiver’s subpredicates.

Constants

LogicalType

These constants describe the possible types of NSCompoundPredicate.

Relationships

Inherits From

Conforms To