issues
search
jiangleligejiang
/
JNote
记录相关日常笔记
0
stars
0
forks
source link
Runtime应用
#80
Open
jiangleligejiang
opened
4 years ago
jiangleligejiang
commented
4 years ago
自定义KVO
KVO基于Runtime实现的
A监听B,系统会创建子类(NSKVONotifying_B)
objc_allocateClassPair
objc_registerClassPair
B的isa ----- NSKVONotifying_B
objc_setClass
重写setter方法
class_addMethod
调用父类方法
objc_msgSendSuper
objc_msgSend调用@selector(observeValueForKeyPath:ofObject:change:context:)
jiangleligejiang
commented
4 years ago
字典模型互转
字典转模型
遍历字典获取key和value
objc_msgSend() --- 调用set赋值
函数指针的写法:
returntype (^name) (param1, param2)
模型转字典
key值:class_copyPropertyList、property_getName
((id(*)(id, SEL))objc_msgSend)(self, sel)
jiangleligejiang
commented
4 years ago
消息转发机制
动态方法解析(resolveInstanceMethod)
快速转发(forwardingTargetForSelector)
慢速转发
methodSignatureForSelector
forwardingInvocation
自定义KVO