NSComparisonPredicate initWithLeftExpression
- (id)initWithLeftExpression:(NSExpression *)lhs rightExpression:(NSExpression *)rhs customSelector:(SEL)selector
Parameters of [NSComparisonPredicate initWithLeftExpression]
lhs
The left hand expression.
rhs
The right hand expression.
selector
The selector to use. The method defined by the selector must take a single argument and return a BOOL value.
Return Value of [NSComparisonPredicate initWithLeftExpression]
The receiver, initialized by combining the left and right expressions using selector.
NSComparisonPredicate initWithLeftExpression example.
NSExpression *nameExpression = [NSExpression expressionForKeyPath:@"name"];
NSArray *operators = [NSArray arrayWithObjects:
[NSNumber numberWithInt: NSEqualToPredicateOperatorType],
[NSNumber numberWithInt:NSNotEqualToPredicateOperatorType],
[NSNumber numberWithInt:NSLikePredicateOperatorType],
[NSNumber numberWithInt:NSBeginsWithPredicateOperatorType],
[NSNumber numberWithInt:NSEndsWithPredicateOperatorType],
[NSNumber numberWithInt:NSContainsPredicateOperatorType],
nil];
NSUInteger options = (NSCaseInsensitivePredicateOption |
NSDiacriticInsensitivePredicateOption);
NSPredicateEditorRowTemplate *template = [[NSPredicateEditorRowTemplate alloc]
initWithLeftExpressions:[NSArray arrayWithObject:nameExpression]
rightExpressionAttributeType:NSStringAttributeType
modifier:NSDirectPredicateModifier
operators:operators
options:options];
NSArray *operators = [NSArray arrayWithObjects:
[NSNumber numberWithInt: NSEqualToPredicateOperatorType],
[NSNumber numberWithInt:NSNotEqualToPredicateOperatorType],
[NSNumber numberWithInt:NSLikePredicateOperatorType],
[NSNumber numberWithInt:NSBeginsWithPredicateOperatorType],
[NSNumber numberWithInt:NSEndsWithPredicateOperatorType],
[NSNumber numberWithInt:NSContainsPredicateOperatorType],
nil];
NSUInteger options = (NSCaseInsensitivePredicateOption |
NSDiacriticInsensitivePredicateOption);
NSPredicateEditorRowTemplate *template = [[NSPredicateEditorRowTemplate alloc]
initWithLeftExpressions:[NSArray arrayWithObject:nameExpression]
rightExpressionAttributeType:NSStringAttributeType
modifier:NSDirectPredicateModifier
operators:operators
options:options];