zoukankan      html  css  js  c++  java
  • KVC and Scalar

    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.

  • 相关阅读:
    Java接口总结
    java面向对象特点总结
    二分查找的两种实现方法
    关于Java的对象equals方法
    java加密枝术是怎样的?
    Java中子类和父类间的调用关系
    Java中字符串的完美度
    Java源代码不编译到字节码文件
    java生成6位随机数
    Struts2中ModelDriven的使用
  • 原文地址:https://www.cnblogs.com/feng9exe/p/7055188.html
Copyright © 2011-2022 走看看