A specialized predicate that evaluates logical combinations of other predicates.


class NSCompoundPredicate : NSPredicate


Use NSCompoundPredicate to create an AND or OR compound predicate of zero or more other predicates, or the NOT of a single predicate. For the logical AND and OR operations:

  • 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.



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.


enum NSCompoundPredicate.LogicalType

These constants describe the possible types of NSCompoundPredicate.


Inherits From

Conforms To

See Also


class NSPredicate

A definition of logical conditions used to constrain a search either for a fetch or for in-memory filtering.

class NSExpression

An expression for use in a comparison predicate.

class NSComparisonPredicate

A specialized predicate that you use to compare expressions.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software