<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSAtomicStoreCacheNode/setValue(_:forKey:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAtomicStoreCacheNode(im)setValue:forKey:"
  },
  "title" : "setValue(_:forKey:)"
}
-->

# setValue(_:forKey:)

Sets the value for the given key.

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

## Parameters

`value`

The value for the property identified by `key`.

`key`

The name of a property.

## Discussion

The default implementation forwards the request to the [`propertyCache`](/documentation/CoreData/NSAtomicStoreCacheNode/propertyCache) dictionary if `key` matches a property name of the entity for this cache node. If `key` does not represent a property, the standard <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/setValue(_:forKey:)> implementation is used.

---

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)