---
title: "setValue(_:forKey:)"
framework: quartzcore
role: symbol
role_heading: Type Method
path: "quartzcore/catransaction/setvalue(_:forkey:)"
---

# setValue(_:forKey:)

Sets the arbitrary keyed-data for the specified key.

## Declaration

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

## Parameters

- `anObject`: The value for the key identified by key.
- `key`: The name of one of the receiver’s properties.

## Discussion

Discussion Nested transactions have nested data scope; setting a key always sets it in the innermost scope.

## See Also

### Getting and Setting Transaction Properties

- [value(forKey:)](quartzcore/catransaction/value(forkey:).md)
