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

# setValue(_:forKey:)

Invokes setValue(_:forKey:) on each of the array’s items using the specified value and key.

## Declaration

```swift
func setValue(_ value: Any?, forKey key: String)
```

## Parameters

- `value`: The object value.
- `key`: The key to store the value.

## See Also

### Key-Value Coding

- [value(forKey:)](foundation/nsarray/value(forkey:).md)
