storedValue(forKey:)
Returns the property identified by a given key.
Declaration
func storedValue(forKey key: String) -> Any?Discussion
This method is used when the value is retrieved for storage in an object store (generally, this storage is ultimately in a database) or for inclusion in a snapshot. The default implementation is similar to the implementation of value(forKey:), but it resolves key with a different method/instance variable search order:
Searches for a private accessor method based on
key(a method preceded by an underbar). For example, with akeyof “lastName”, storedValue(forKey:) looks for a method named_getLastNameor_lastName.If a private accessor is not found, searches for an instance variable based on
keyand returns its value directly. For example, with akeyof “lastName”, storedValue(forKey:) looks for an instance variable named_lastNameorlastName.If neither a private accessor nor an instance variable is found, storedValue(forKey:) searches for a public accessor method based on
key. For thekey“lastName”, this would begetLastNameorlastName.If
keyis unknown, storedValue(forKey:) calls handleTakeValue(_:forUnboundKey:).
This different search order allows an object to bypass processing that is performed before returning a value through a public API. However, if you always want to use the search order in value(forKey:), you can implement the class method useStoredAccessor() to return NO. And as with value(forKey:), you can prevent direct access of an instance variable with the class method accessInstanceVariablesDirectly.
See Also
Deprecated Methods
accessibilityAttributeNames()accessibilityAttributeValue(_:)accessibilityAttributeValue(_:forParameter:)accessibilityActionDescription(_:)accessibilityActionNames()accessibilityArrayAttributeCount(_:)accessibilityArrayAttributeValues(_:index:maxCount:)accessibilityIndex(ofChild:)accessibilityIsAttributeSettable(_:)accessibilityIsIgnored()accessibilityParameterizedAttributeNames()accessibilityPerformAction(_:)accessibilitySetOverrideValue(_:forAttribute:)accessibilitySetValue(_:forAttribute:)fileManager(_:shouldProceedAfterError:)