Ultimately I'd like to write complex predicates, for example, to filter using either a custom function or a block. The reason I need this is to validate edits to an NSTableView using bindings. According to the docs:
A predicate is a logical operator that returns a Boolean value (true or false). There are two types of predicate; comparison predicates, and compound predicates:
● A comparison predicate compares two expressions using an operator. The expressions are referred to as the left hand side and the right hand side of the predicate (with the operator in the middle). A comparison predicate returns the result of invoking the operator with the results of evaluating the expressions.
● A compound predicate compares the results of evaluating two or more other other predicates, or negates another predicate.
All the code is like this:
compiled and run like this:
Example 1. Predicate with a format string using "like"
(the c is a case-insensitive compare, the * is a wild card):
Example 2. Format string with a mathematical operator
Note: also works with the usual kind of string formatting
:@"SELF > %d ", 4