Here is another example which looks less forbidding: it combines two expressions in a single predicate. These can then be used to construct a comparison predicate that grabs the object for key='value' from an array, and checks it against the number 10, like this:
As before the code block is inside a standard main:
and compiled like this:
code:
Here is a second example, taken from the docs, of how to construct an expression that uses a built-in function (they call this a function expression):
There are lots of built-in functions available (here).
The third example is based on the first part (the simple part) of this post from Dave DeLong. It defines a category on NSNumber
and the code block is:
And now, the way to solve my initial question seems clear:
Define a category on NSString that does what I want.
Wrap the call up in an NSExpression and then an NSPredicate. Next time, if I succeed.