https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/KeyValueCoding/DataTypes.html
The default implementation of the key-value coding protocol methods provided by NSObject
work with both object and non-object properties. The default implementation automatically translates between object parameters or return values, and non-object properties. This allows the signatures of the key-based getters and setters to remain consistent even when the stored property is a scalar or a structure.
NOTE
Because all properties in Swift are objects, this section only apples to Objective-C properties.
When you invoke one of the protocol’s getters, such as valueForKey:
, the default implementation determines the particular accessor method or instance variable that supplies the value for the specified key according to the rules described in Accessor Search Patterns. If the return value is not an object, the getter uses this value to initialize an NSNumber
object (for scalars) or NSValue
object (for structures) and returns that instead.
Similarly, by default, setters like setValue:forKey:
determine the data type required by a property’s accessor or instance variable, given a particular key. If the data type is not an object, the setter first sends an appropriate <type>Value
message to the incoming value object to extract the underlying data, and stores that instead.