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

# primitiveValue(forKey:)

Returns the value for the specified property from the managed object’s private internal storage .

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

## Parameters

`key`

The name of one of the receiver’s properties.

## Return Value

The value of the property specified by `key`. Returns `nil` if no value has been set.

## Discussion

This method does not invoke the access notification methods ([`willAccessValue(forKey:)`](/documentation/CoreData/NSManagedObject/willAccessValue(forKey:)) and [`didAccessValue(forKey:)`](/documentation/CoreData/NSManagedObject/didAccessValue(forKey:))). This method is used primarily by subclasses that implement custom accessor methods that need direct access to the receiver’s private storage.

### Special Considerations

Subclasses should not override this method.

The following points also apply:

- Primitive accessor methods are only supported on *modeled* properties. If you invoke a primitive accessor on an unmodeled property, it will instead operate upon a random modeled property. (The debug libraries and frameworks (available from [Apple Developer Website](http://developer.apple.com/)) have assertions to test for passing unmodeled keys to these methods.)
- You are strongly encouraged to use the dynamically-generated accessors rather than using this method directly (for example, `primitiveName:` instead of `primitiveValueForKey:@"name"`). The dynamic accessors are much more efficient, and allow for compile-time checking.

## See Also

[`setObservationInfo(_:)`](/documentation/CoreData/NSManagedObject/setObservationInfo(_:))

Sets the observation info of the managed object.



---

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)