NSCompoundPredicate Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in OS X v10.4 and later. |
| Companion guide | |
| Declared in | NSCompoundPredicate.h |
Overview
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.
In OS X v10.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.
Tasks
Constructors
-
+ andPredicateWithSubpredicates: -
+ notPredicateWithSubpredicate: -
+ orPredicateWithSubpredicates: -
– initWithType:subpredicates:
Getting Information About a Compound Predicate
Class Methods
andPredicateWithSubpredicates:
Returns a new predicate formed by AND-ing the predicates in a given array.
Parameters
- subpredicates
An array of
NSPredicateobjects.
Return Value
A new predicate formed by AND-ing the predicates specified by subpredicates.
Discussion
An AND predicate with no subpredicates evaluates to TRUE.
Special Considerations
For applications linked on OS X v10.5 or later, the subpredicates array is copied. For applications linked on OS X v10.4, the subpredicates array is retained (for binary compatibility).
Availability
- Available in OS X v10.4 and later.
Declared In
NSCompoundPredicate.hnotPredicateWithSubpredicate:
Returns a new predicate formed by NOT-ing a given predicate.
Parameters
- predicate
A predicate.
Return Value
A new predicate formed by NOT-ing the predicate specified by predicate.
Special Considerations
For applications linked on OS X v10.5 or later, the subpredicates array is copied. For applications linked on OS X v10.4, the subpredicates array is retained (for binary compatibility).
Availability
- Available in OS X v10.4 and later.
Declared In
NSCompoundPredicate.horPredicateWithSubpredicates:
Returns a new predicate formed by OR-ing the predicates in a given array.
Parameters
- subpredicates
An array of
NSPredicateobjects.
Return Value
A new predicate formed by OR-ing the predicates specified by subpredicates.
Discussion
An OR predicate with no subpredicates evaluates to FALSE.
Special Considerations
For applications linked on OS X v10.5 or later, the subpredicates array is copied. For applications linked on OS X v10.4, the subpredicates array is retained (for binary compatibility).
Availability
- Available in OS X v10.4 and later.
Declared In
NSCompoundPredicate.hInstance Methods
compoundPredicateType
Returns the predicate type for the receiver.
Return Value
The predicate type for the receiver.
Availability
- Available in OS X v10.4 and later.
Declared In
NSCompoundPredicate.hinitWithType:subpredicates:
Returns the receiver initialized to a given type using predicates from a given array.
Parameters
- type
The type of the new predicate.
- subpredicates
An array of
NSPredicateobjects.
Return Value
The receiver initialized with its type set to type and subpredicates array to subpredicates.
Special Considerations
For applications linked on OS X v10.5 or later, the subpredicates array is copied. For applications linked on OS X v10.4, the subpredicates array is retained (for binary compatibility).
Availability
- Available in OS X v10.4 and later.
Declared In
NSCompoundPredicate.hsubpredicates
Returns the array of the receiver’s subpredicates.
Return Value
The array of the receiver’s subpredicates.
Availability
- Available in OS X v10.4 and later.
Declared In
NSCompoundPredicate.hConstants
Compound Predicate Types
These constants describe the possible types of NSCompoundPredicate.
typedef enum {
NSNotPredicateType = 0,
NSAndPredicateType,
NSOrPredicateType,
} NSCompoundPredicateType;
Constants
NSNotPredicateTypeA logical NOT predicate.
Available in OS X v10.4 and later.
Declared in
NSCompoundPredicate.h.NSAndPredicateTypeA logical AND predicate.
Available in OS X v10.4 and later.
Declared in
NSCompoundPredicate.h.NSOrPredicateTypeA logical OR predicate.
Available in OS X v10.4 and later.
Declared in
NSCompoundPredicate.h.
Declared In
NSCompoundPredicate.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-10-14)