<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "QuartzCore",
  "identifier" : "/documentation/QuartzCore/CATransaction/setValue(_:forKey:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Core Animation"
    ],
    "preciseIdentifier" : "c:objc(cs)CATransaction(cm)setValue:forKey:"
  },
  "title" : "setValue(_:forKey:)"
}
-->

# setValue(_:forKey:)

Sets the arbitrary keyed-data for the specified key.

```
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

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

---

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)