primitiveValue(forKey:)
Returns the value for the specified property from the managed object’s private internal storage .
Declaration
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:) and 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) 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 ofprimitiveValueForKey:@"name"). The dynamic accessors are much more efficient, and allow for compile-time checking.