KVO官方文档学习(五)----KVO实现细节
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 theisa
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 方法来确定一个对象实例的类。