底层-KVO
2020-01-09 本文已影响0人
Stago
KVO
-
KVO的全称是Key-Value Observing,俗称“键值监听”,可以用于监听某个对象属性值的改变
未使用KVO监听的对象

使用了KVO监听的对象

查看_NSSet*AndNotify的存在

_NSSet*ValueAndNotify的内部实现

- 调用willChangeValueForKey:
- 调用原来的setter实现
- 调用didChangeValueForKey:
didChangeValueForKey:内部会调用observer的observeValueForKeyPath:ofObject:change:context:方法