NSComparisonPredicate initWithLeftExpression rightExpression modifier type options
- (id)initWithLeftExpression:(NSExpression *)lhs rightExpression:(NSExpression *)rhs modifier:(NSComparisonPredicateModifier)modifier type:(NSPredicateOperatorType)type options:(NSUInteger)options
Parameters of [NSComparisonPredicate initWithLeftExpression rightExpression modifier type options]
lhs
The left hand expression.
rhs
The right hand expression.
modifier
The modifier to apply.
type
The predicate operator type.
options
The options to apply (see “NSComparisonPredicate Options”). For no options, pass 0.
Return Value of [NSComparisonPredicate initWithLeftExpression rightExpression modifier type options]
The receiver, initialized to a predicate of type type formed by combining the left and right expressions using the modifier and options.
NSComparisonPredicate initWithLeftExpression rightExpression modifier type options 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];