API  0.9.6
 All Classes Files Functions Variables Macros Modules Pages
CPPredicate Class Reference

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:
 
- Instance Methods inherited from CPObject
(void) - addObserver:forKeyPath:options:context:
 
(void) - applyChange:toKeyPath:
 
(id) - autorelease
 
(id) - awakeAfterUsingCoder:
 
(void) - awakeFromCib
 
(void) - bind:toObject:withKeyPath:options:
 
(Class) - classForCoder
 
(Class) - classForKeyedArchiver
 
(CPString- className
 
(id) - copy
 
(void) - dealloc
 
(CPDictionary- dictionaryWithValuesForKeys:
 
(void) - didChange:valuesAtIndexes:forKey:
 
(void) - didChangeValueForKey:
 
(void) - didChangeValueForKey:withSetMutation:usingObjects:
 
(void) - doesNotRecognizeSelector:
 
(CPArray- exposedBindings
 
(id) - forwardingTargetForSelector:
 
(void) - forwardInvocation:
 
(unsigned) - hash
 
(BOOL) - implementsSelector:
 
(CPDictionary- infoForBinding:
 
(id) - init
 
(BOOL) - isEqual:
 
(BOOL) - isKindOfClass:
 
(BOOL) - isMemberOfClass:
 
(BOOL) - isProxy
 
(IMP) - methodForSelector:
 
(CPMethodSignature) - methodSignatureForSelector:
 
(id) - mutableArrayValueForKey:
 
(id) - mutableArrayValueForKeyPath:
 
(id) - mutableCopy
 
(id) - mutableSetValueForKey:
 
(id) - mutableSetValueForKeyPath:
 
(id) - performSelector:
 
(id) - performSelector:withObject:
 
(id) - performSelector:withObject:withObject:
 
(id) - performSelector:withObjects:
 
(void) - release
 
(void) - removeObserver:forKeyPath:
 
(id) - replacementObjectForArchiver:
 
(id) - replacementObjectForCoder:
 
(id) - replacementObjectForKeyedArchiver:
 
(BOOL) - respondsToSelector:
 
(id) - retain
 
(id) - self
 
(void) - setValue:forKey:
 
(void) - setValue:forKeyPath:
 
(void) - setValue:forUndefinedKey:
 
(void) - setValuesForKeysWithDictionary:
 
(CPString- UID
 
(void) - unbind:
 
(Class) - valueClassForBinding:
 
(id) - valueForKey:
 
(id) - valueForKeyPath:
 
(id) - valueForUndefinedKey:
 
(void) - willChange:valuesAtIndexes:forKey:
 
(void) - willChangeValueForKey:
 
(void) - willChangeValueForKey:withSetMutation:usingObjects:
 

Class Methods

(CPPredicate+ predicateWithFormat:
 
(CPPredicate+ predicateWithFormat:argumentArray:
 
(CPPredicate+ predicateWithFormat:arguments:
 
(CPPredicate+ predicateWithValue:
 
- Class Methods inherited from CPObject
(BOOL) + accessInstanceVariablesDirectly
 
(id) + alloc
 
(id) + allocWithCoder:
 
(BOOL) + automaticallyNotifiesObserversForKey:
 
(Class) + class
 
(void) + exposeBinding:
 
(void) + initialize
 
(IMP) + instanceMethodForSelector:
 
(BOOL) + instancesRespondToSelector:
 
(BOOL) + isSubclassOfClass:
 
(CPSet+ keyPathsForValuesAffectingValueForKey:
 
(void) + load
 
(id) + new
 
(void) + setVersion:
 
(Class) + superclass
 
(int) + version
 

Additional Inherited Members

- Instance Variables inherited from CPObject
Class isa
 

Detailed Description

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:

  • Simple comparisons, such as grade == "7" or firstName like "Shaffiq"
  • Case/diacritic insensitive lookups, such as name contains[cd] "itroen"
  • Logical operations, such as (firstName like "Mark") OR (lastName like "Adderley")
  • “Between” predicates such as date between {$YESTERDAY, $TOMORROW}.

You can create predicates for relationships, such as:

  • group.name like "work*"
  • ALL children.age > 12
  • ANY children.age > 12

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

Method Documentation

- (CPString) description
implementation

Returns a human readable string describing the receiver

Reimplemented from CPObject.

Definition at line 153 of file CPPredicate.j.

- (BOOL) evaluateWithObject: (id)  object
implementation

Returns a Boolean value that indicates whether a given object matches the conditions specified by the receiver.

Parameters
objectThe object against which to evaluate the receiver.
Returns
YES if object matches the conditions specified by the receiver, otherwise NO.

Reimplemented in CPComparisonPredicate, and CPCompoundPredicate.

Definition at line 127 of file CPPredicate.j.

- (BOOL) evaluateWithObject: (id)  object
substitutionVariables: (CPDictionary variables 
implementation

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.

Parameters
objectThe object against which to evaluate the receiver.
variablesThe substitution variables dictionary. The dictionary must contain key-value pairs for all variables in the receiver.
Returns
YES if object matches the conditions specified by the receiver after substituting in the values in variables for any replacement tokens, otherwise NO.

Reimplemented in CPComparisonPredicate, and CPCompoundPredicate.

Definition at line 138 of file CPPredicate.j.

- (CPString) predicateFormat
implementation

Returns the receiver’s format string.

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
,   ... 
implementation

Creates and returns a new predicate formed by creating a new string with a given format and parsing the result.

Parameters
formatThe format string for the new predicate.
A comma-separated list of arguments to substitute into format.
Returns
A new predicate formed by creating a new string with format and parsing the result.

Definition at line 63 of file CPPredicate.j.

+ (CPPredicate) predicateWithFormat: (CPString format
argumentArray: (CPArray args 
implementation

Creates and returns a new predicate by substituting the values in a given array into a format string and parsing the result.

Parameters
formatThe format string for the new predicate.
argumentsThe arguments to substitute into predicateFormat. Values are substituted into predicateFormat in the order they appear in the array.
Returns
A new predicate by substituting the values in arguments into predicateFormat, and parsing the result.

Definition at line 78 of file CPPredicate.j.

+ (CPPredicate) predicateWithFormat: (CPString format
arguments: (va_list)  argList 
implementation

Creates and returns a new predicate by substituting the values in an argument list into a format string and parsing the result.

Parameters
formatThe format string for the new predicate.
argListThe arguments to substitute into predicateFormat. Values are substituted into predicateFormat in the order they appear in the argument list.
Returns
A new predicate by substituting the values in argList into predicateFormat and parsing the result.

Definition at line 95 of file CPPredicate.j.

- (CPPredicate) predicateWithSubstitutionVariables: (CPDictionary variables
implementation

Returns a copy of the receiver with the receiver’s variables substituted by values specified in a given substitution variables dictionary.

Parameters
variablesThe substitution variables dictionary. The dictionary must contain key-value pairs for all variables in the receiver.
Returns
A copy of the receiver with the receiver’s variables substituted by values specified in variables.

Reimplemented in CPComparisonPredicate, and CPCompoundPredicate.

Definition at line 106 of file CPPredicate.j.

+ (CPPredicate) predicateWithValue: (BOOL)  value
implementation

Creates and returns a predicate that always evaluates to a given value.

Parameters
valueThe value to which the new predicate should evaluate.
Returns
A predicate that always evaluates to value.

Definition at line 116 of file CPPredicate.j.


The documentation for this class was generated from the following files: