KVO VS isa : KVO 建立在 KVC 之上

Key-Value Observing (KVO) 建立在 KVC 之上,它通过重写 KVC 和监听 setter 方法,向外发送通知。

https://blog.csdn.net/y550918116j/article/details/64906862

 

猜测:KVO 保留的原来的类引用,用于返回class值;

 

(lldb) po self.scrollView.class
UITableView

(lldb) po self.scrollView->isa
NSKVONotifying_UITableView

 

Automatic key-value observing is implemented using a technique called 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. 

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. 

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.

 


- class { return (id)isa; }

转载于:https://www.cnblogs.com/feng9exe/p/8671550.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值