Friday, June 14, 2013

NSComparisonPredicate NSNotEqualToPredicateOperatorType example in Objective C (iOS).


NSComparisonPredicate NSNotEqualToPredicateOperatorType

NSPredicateOperatorType
Defines the type of comparison for NSComparisonPredicate.

enum {
NSLessThanPredicateOperatorType = 0,
NSLessThanOrEqualToPredicateOperatorType,
NSGreaterThanPredicateOperatorType,
NSGreaterThanOrEqualToPredicateOperatorType,
NSEqualToPredicateOperatorType,
NSNotEqualToPredicateOperatorType,
NSMatchesPredicateOperatorType,
NSLikePredicateOperatorType,
NSBeginsWithPredicateOperatorType,
NSEndsWithPredicateOperatorType,
NSInPredicateOperatorType,
NSCustomSelectorPredicateOperatorType,
NSContainsPredicateOperatorType,
NSBetweenPredicateOperatorType
};
typedef NSUInteger NSPredicateOperatorType;

Constants
NSLessThanPredicateOperatorType
A less-than predicate.
NSLessThanOrEqualToPredicateOperatorType
A less-than-or-equal-to predicate.
NSGreaterThanPredicateOperatorType
A greater-than predicate.
NSGreaterThanOrEqualToPredicateOperatorType
A greater-than-or-equal-to predicate.
NSEqualToPredicateOperatorType
An equal-to predicate.
NSNotEqualToPredicateOperatorType
A not-equal-to predicate.
NSMatchesPredicateOperatorType
A full regular expression matching predicate.
NSLikePredicateOperatorType
A simple subset of the MATCHES predicate, similar in behavior to SQL LIKE.
NSBeginsWithPredicateOperatorType
A begins-with predicate.
NSEndsWithPredicateOperatorType
An ends-with predicate.
NSInPredicateOperatorType
A predicate to determine if the left hand side is in the right hand side.
For strings, returns YES if the left hand side is a substring of the right hand side . For collections, returns YES if the left hand side is in the right hand side .
NSCustomSelectorPredicateOperatorType
A predicate that uses a custom selector that takes a single argument and returns a BOOL value.
The selector is invoked on the left hand side with the right hand side as the argument.
NSContainsPredicateOperatorType
A predicate to determine if the left hand side contains the right hand side.
Returns YES if [lhs contains rhs]; the left hand side must be an NSExpression object that evaluates to a collection
NSBetweenPredicateOperatorType
A predicate to determine if the right hand side lies at or between bounds specified by the left hand side.
Returns YES if [lhs between rhs]; the right hand side must be an array in which the first element sets the lower bound and the second element the upper, inclusive. Comparison is performed using compare: or the class-appropriate equivalent.

NSComparisonPredicate NSNotEqualToPredicateOperatorType 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];

End of NSComparisonPredicate NSNotEqualToPredicateOperatorType example article.