Cocoa defines predicate classes (NSPredicate
, NSExpression
, etc.) which "provide a general means of specifying queries in Cocoa" Predicate Programming. This set of classes describes what I need but with one little short-coming : I'd like additional operators.
NSComparisonPredicate
already handles 14 operators (NSPredicateOperatorType) but I would like to add, say, temporal operators... or operators to represent things such as:
- " variable has at least n entries" (binary operator)
- " variable has value for, at most, n consecutive days" (ternary operator)
Obviously, I would need to implement these myself and the data model on which such queries are performed will have to support these operators. But, is there a way to implement it and benefit from the existing NSPredicate classes? Since operators were defined as an enum
, I doubt I can extend on that front. Or am I completely missing the boat on this?!