一、KVO
1、KVO的全称是Key-Value-Observing,俗称“键值监听”,可以用于监听某个对象属性值的改变
2、KVO通过Runtime动态生成一个全新的子类NSKVONotifying_MJPerson,然后让instance对象的isa指针指向这个全新的子类

3、KVO监听对象 重新生成全新的子类内部包括

4、内部实现Class重写操作,屏蔽内部实现 隐藏了NSKVONotifying_MJPerson类的存在

5、如何打印类内部的方法名

6、iOS用什么方式实现对一个对象的KVO(KVO的本质是什么?)

二、KVC
1、KVC的全称是Key-Value-Coding,俗称“键值编码”,可以通过一个key来访问某个属性
常用的API有
// 设置值
- (void)setValue:(nullable id)value forKeyPath:(NSString *)keyPath;
- (void)setValue:(nullable id)value forKey:(NSString *)key;
// 获取值
- (nullable id)valueForKeyPath:(NSString *)keyPath;
- (nullable id)valueForKey:(NSString *)key;
2、setValue:forKey:的原理

3、valueForKey:的原理

网友评论