| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in Mac OS X v10.4 and later. |
| Companion guide | |
| Declared in | NSCompoundPredicate.h |
| Related sample code |
NSCompoundPredicate is a subclass of NSPredicate used to represent logical “gate” operations (AND/OR/NOT) and comparison operations.
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.
On Mac OS X v10.5 and later and on iPhone OS, NSCompoundPredicate allows you to create an AND or OR compound predicate (but not a NOT compound predicate) using an array with 0, 1, or more elements. A compound predicate with 0 elements evaluates to TRUE, and a compound predicate with a single sub-predicate evaluates to the truth of its sole subpredicate.
+ andPredicateWithSubpredicates:
+ notPredicateWithSubpredicate:
+ orPredicateWithSubpredicates:
– initWithType:subpredicates:
Returns a new predicate formed by AND-ing the predicates in a given array.
+ (NSPredicate *)andPredicateWithSubpredicates:(NSArray *)subpredicates
An array of NSPredicate objects.
A new predicate formed by AND-ing the predicates specified by subpredicates.
NSCompoundPredicate.h
Returns a new predicate formed by NOT-ing a given predicate.
+ (NSPredicate *)notPredicateWithSubpredicate:(NSPredicate *)predicate
A predicate.
A new predicate formed by NOT-ing the predicate specified by predicate.
NSCompoundPredicate.h
Returns a new predicate formed by OR-ing the predicates in a given array.
+ (NSPredicate *)orPredicateWithSubpredicates:(NSArray *)subpredicates
An array of NSPredicate objects.
A new predicate formed by OR-ing the predicates specified by subpredicates.
NSCompoundPredicate.hReturns the predicate type for the receiver.
- (NSCompoundPredicateType)compoundPredicateType
The predicate type for the receiver.
NSCompoundPredicate.hReturns the receiver initialized to a given type using predicates from a given array.
- (id)initWithType:(NSCompoundPredicateType)type subpredicates:(NSArray *)subpredicates
The type of the new predicate.
An array of NSPredicate objects.
The receiver initialized with its type set to type and subpredicates array to subpredicates.
NSCompoundPredicate.hReturns the array of the receiver’s subpredicates.
- (NSArray *)subpredicates
The array of the receiver’s subpredicates.
NSCompoundPredicate.hThese constants describe the possible types of NSCompoundPredicate.
typedef enum {
NSNotPredicateType = 0,
NSAndPredicateType,
NSOrPredicateType,
} NSCompoundPredicateType;
NSNotPredicateTypeA logical NOT predicate.
Available in Mac OS X v10.4 and later.
Declared in NSCompoundPredicate.h.
NSAndPredicateTypeA logical AND predicate.
Available in Mac OS X v10.4 and later.
Declared in NSCompoundPredicate.h.
NSOrPredicateTypeA logical OR predicate.
Available in Mac OS X v10.4 and later.
Declared in NSCompoundPredicate.h.
NSCompoundPredicate.h
Last updated: 2009-02-19