![]() |
API 0.9.5
|
The CPPredicate class is used to define logical conditions used to constrain a search either for a fetch or for in-memory filtering. More...
#import <CPPredicate.h>
Inheritance diagram for CPPredicate:Instance Methods | |
| (CPString) | - description |
| (BOOL) | - evaluateWithObject: |
| (BOOL) | - evaluateWithObject:substitutionVariables: |
| (CPString) | - predicateFormat |
| (CPPredicate) | - predicateWithSubstitutionVariables: |
Class Methods | |
| (CPPredicate) | + predicateWithFormat: |
| (CPPredicate) | + predicateWithFormat:argumentArray: |
| (CPPredicate) | + predicateWithFormat:arguments: |
| (CPPredicate) | + predicateWithValue: |
The CPPredicate class is used to define logical conditions used to constrain a search either for a fetch or for in-memory filtering.
You use predicates to represent logical conditions, used for describing objects in persistent stores and in-memory filtering of objects. Although it is common to create predicates directly from instances of CPComparisonPredicate, CPCompoundPredicate, and CPExpression, you often create predicates from a format string which is parsed by the class methods on CPPredicate. Examples of predicate format strings include:
grade == "7" or firstName like "Shaffiq"name contains[cd] "itroen"(firstName like "Mark") OR (lastName like "Adderley")date between {$YESTERDAY, $TOMORROW}.You can create predicates for relationships, such as:
group.name like "work*"ALL children.age > 12ANY children.age > 12You can create predicates for operations, such as @sum.items.price < 1000.
You can also create predicates that include variables, so that the predicate can be pre-defined before substituting concrete values at runtime with the evaluateWithObject:substitutionVariables: method.
Definition at line 2 of file CPPredicate.h.
| - (CPString) description |
Definition at line 153 of file CPPredicate.j.
| - (BOOL) evaluateWithObject: | (id) | object |
Returns a Boolean value that indicates whether a given object matches the conditions specified by the receiver.
| object | The object against which to evaluate the receiver. |
Reimplemented in CPComparisonPredicate, and CPCompoundPredicate.
Definition at line 127 of file CPPredicate.j.
| - (BOOL) evaluateWithObject: | (id) | object | |
| substitutionVariables: | (CPDictionary) | variables | |
Returns a Boolean value that indicates whether a given object matches the conditions specified by the receiver after substituting in the values in a given variables dictionary.
| object | The object against which to evaluate the receiver. |
| variables | The substitution variables dictionary. The dictionary must contain key-value pairs for all variables in the receiver. |
Reimplemented in CPComparisonPredicate, and CPCompoundPredicate.
Definition at line 138 of file CPPredicate.j.
| - (CPString) predicateFormat |
Returns the receiver’s format string.
Reimplemented in CPComparisonPredicate, CPCompoundPredicate, and CPPredicate_BOOL.
Definition at line 148 of file CPPredicate.j.
| + (CPPredicate) predicateWithFormat: | (CPString) | format | |
| , | ... | ||
Creates and returns a new predicate formed by creating a new string with a given format and parsing the result.
| format | The format string for the new predicate. |
| … | A comma-separated list of arguments to substitute into format. |
Definition at line 63 of file CPPredicate.j.
| + (CPPredicate) predicateWithFormat: | (CPString) | format | |
| argumentArray: | (CPArray) | args | |
Creates and returns a new predicate by substituting the values in a given array into a format string and parsing the result.
| format | The format string for the new predicate. |
| arguments | The arguments to substitute into predicateFormat. Values are substituted into predicateFormat in the order they appear in the array. |
Definition at line 78 of file CPPredicate.j.
| + (CPPredicate) predicateWithFormat: | (CPString) | format | |
| arguments: | (va_list) | argList | |
Creates and returns a new predicate by substituting the values in an argument list into a format string and parsing the result.
| format | The format string for the new predicate. |
| argList | The arguments to substitute into predicateFormat. Values are substituted into predicateFormat in the order they appear in the argument list. |
Definition at line 95 of file CPPredicate.j.
| - (CPPredicate) predicateWithSubstitutionVariables: | (CPDictionary) | variables |
Returns a copy of the receiver with the receiver’s variables substituted by values specified in a given substitution variables dictionary.
| variables | The substitution variables dictionary. The dictionary must contain key-value pairs for all variables in the receiver. |
Reimplemented in CPComparisonPredicate, and CPCompoundPredicate.
Definition at line 106 of file CPPredicate.j.
| + (CPPredicate) predicateWithValue: | (BOOL) | value |
Creates and returns a predicate that always evaluates to a given value.
| value | The value to which the new predicate should evaluate. |
Definition at line 116 of file CPPredicate.j.