<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSExpression/init(block:arguments:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSExpression(cm)expressionForBlock:arguments:"
  },
  "title" : "init(block:arguments:)"
}
-->

# init(block:arguments:)

Creates an expression object that uses the block for evaluating objects.

```
init(block: @escaping (Any?, [NSExpression], NSMutableDictionary?) -> Any, arguments: [NSExpression]?)
```

## Parameters

`block`

The Block is applied to the object to be evaluated.

    The Block takes three arguments and returns a value:

- evaluatedObject: The object to be evaluated.
- expressions: An array of predicate expressions that evaluates to a collection.
- context: 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`    .

`arguments`

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 [`init(forFunction:arguments:)`](/documentation/Foundation/NSExpression/init(forFunction:arguments:))     for a complete list of arguments.

## Return Value

An expression that filters a collection using the specified Block.

## See Also

[`expressionBlock`](/documentation/Foundation/NSExpression/expressionBlock)

The block that executes to evaluate the expression.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)