---
title: "value(forKey:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsarray/value(forkey:)"
---

# value(forKey:)

Returns an array containing the results of invoking value(forKey:) using key on each of the array’s objects.

## Declaration

```swift
func value(forKey key: String) -> Any
```

## Parameters

- `key`: The key to retrieve.

## Return Value

Return Value The value of the retrieved key.

## Discussion

Discussion The returned array contains NSNull elements for each object that returns nil.

## See Also

### Key-Value Coding

- [setValue(_:forKey:)](foundation/nsarray/setvalue(_:forkey:).md)
