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

# value(forKey:)

Returns the value for the property specified by key.

## Declaration

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

## Parameters

- `key`: The name of one of the receiver’s properties.

## Return Value

Return Value The value of the property specified by key.

## Discussion

Discussion If key is not a property defined by the model, the method raises an exception. This method is overridden by NSManagedObject to access the managed object’s generic dictionary storage unless the receiver’s class explicitly provides key-value coding compliant accessor methods for key. important: You must not override this method.

## See Also

### Related Documentation

- [setObservationInfo(_:)](coredata/nsmanagedobject/setobservationinfo(_:).md)

### Supporting Key-Value Coding

- [setValue(_:forKey:)](coredata/nsmanagedobject/setvalue(_:forkey:).md)
- [primitiveValue(forKey:)](coredata/nsmanagedobject/primitivevalue(forkey:).md)
- [setPrimitiveValue(_:forKey:)](coredata/nsmanagedobject/setprimitivevalue(_:forkey:).md)
- [objectIDs(forRelationshipNamed:)](coredata/nsmanagedobject/objectids(forrelationshipnamed:).md)
