美文网首页iOS学习笔记
KVO官方文档学习(五)----KVO实现细节

KVO官方文档学习(五)----KVO实现细节

作者: 郝嗨森 | 来源:发表于2019-01-28 15:03 被阅读1次

    官方文档

    Automatic key-value observing is implemented using a technique called isa-swizzling.

    自动KVO是使用isa-swizzling技术实现的。

    The isa pointer, as the name suggests, points to the object's class which maintains a dispatch table. This dispatch table essentially contains pointers to the methods the class implements, among other data.

    isa指针指向维护了一个调度表的对象的类。该调度表基本上包含了指向类实现的方法的指针,以及其他数据。

    When an observer is registered for an attribute of an object the isa pointer of the observed object is modified, pointing to an intermediate class rather than at the true class. As a result the value of the isa pointer does not necessarily reflect the actual class of the instance.

    当一个针对一个对象的属性的观察者被注册时,被观察对象的isa指针会被修改,指向一个中间类而不是这个真实的类。因此,isa指针的值不一定反映示例的真实类。

    You should never rely on the isa pointer to determine class membership. Instead, you should use the class method to determine the class of an object instance.

    你永远不应该依赖isa指针来决定类成员关系。相反地,你应该使用class 方法来确定一个对象实例的类。

    相关文章

      网友评论

        本文标题:KVO官方文档学习(五)----KVO实现细节

        本文链接:https://www.haomeiwen.com/subject/qheajqtx.html