Type Method


Creates an NSExpression object that will use the Block for evaluating objects.


+ (NSExpression *)expressionForBlock:(id  _Nonnull (^)(id evaluatedObject, NSArray<NSExpression *> *expressions, NSMutableDictionary *context))block arguments:(NSArray<NSExpression *> *)arguments;



The Block is applied to the object to be evaluated.

The Block takes three arguments and returns a value:


The object to be evaluated.


An array of predicate expressions that evaluates to a collection.


A dictionary that the expression can use to store temporary state for one predicate evaluation.

Note that context is mutable, and that it can only be accessed during the evaluation of the expression. You must not attempt to retain it for use elsewhere. ]

The Block returns the evaluatedObject.


An array containing NSExpression objects that will be used as parameters during the invocation of selector.

For a selector taking no parameters, the array should be empty. For a selector taking one or more parameters, the array should contain one NSExpression object which will evaluate to an instance of the appropriate type for each parameter.

If there is a mismatch between the number of parameters expected and the number you provide during evaluation, an exception may be raised or missing parameters may simply be replaced by nil (which occurs depends on how many parameters are provided, and whether you have over- or underflow).

See expressionForFunction:arguments: for a complete list of arguments.

Return Value

An expression that filters a collection using the specified Block.

See Also