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

# value(forKey:)

Returns the value for a given key.

## Declaration

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

## Parameters

- `key`: The name of a property.

## Return Value

Return Value The value for the property named key. For an attribute, the return value is an instance of an attribute type supported by Core Data (see NSAttributeDescription); for a to-one relationship, the return value must be another cache node instance; for a to-many relationship, the return value must be an collection of the related cache nodes.

## Discussion

Discussion The default implementation forwards the request to the propertyCache dictionary if key matches a property name of the entity for the cache node. If key does not represent a property, the standard value(forKey:) implementation is used.

## See Also

### Managing Node Data

- [objectID](coredata/nsatomicstorecachenode/objectid.md)
- [propertyCache](coredata/nsatomicstorecachenode/propertycache.md)
- [setValue(_:forKey:)](coredata/nsatomicstorecachenode/setvalue(_:forkey:).md)
