---
title: "objectsByEvaluating(withContainers:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsscriptobjectspecifier/objectsbyevaluating(withcontainers:)"
---

# objectsByEvaluating(withContainers:)

Returns the actual object or objects specified by the receiver as evaluated in the context of given container object.

## Declaration

```swift
func objectsByEvaluating(withContainers containers: Any) -> Any?
```

## Return Value

Return Value The actual object or objects specified by the receiver as evaluated in the context of its container object or objects (containers).

## Discussion

Discussion Invokes indicesOfObjectsByEvaluating(withContainer:count:) on self to get an array of pointers to indices of elements in containers that have values paired with the message receiver’s key. This method then uses key-value coding to obtain the object or objects associated with the key; it returns these objects or nil if there are no matching values in containers. If there are multiple matching values, they are returned in an NSArray; if matching values are nil, NSNull objects are substituted. If containers is an NSArray, the method recursively evaluates each element in the array and returns an NSArray with evaluated objects (including NSNulls) in their corresponding slots.

## See Also

### Evaluating an object specifier

- [indicesOfObjectsByEvaluating(withContainer:count:)](foundation/nsscriptobjectspecifier/indicesofobjectsbyevaluating(withcontainer:count:).md)
- [objectsByEvaluatingSpecifier](foundation/nsscriptobjectspecifier/objectsbyevaluatingspecifier.md)
