KVO的原理
1,动态生成子类:NSKvoNotifying_xx
2,isa只指向态子类
3,观察的是 setter
4,动态子类重写了很多方法 setter class dealloc _isKVOA
5,移除观察的时候 isa 指向回来
6,动态子类不会销毁
- (void)log:(Class)class
{
unsigned int count = 0;
Method *methodList = class_copyMethodList(class, &count);
for (int i = 0; i < count; i++ ) {
Method method = methodList[i];
SEL sel = method_getName(method);
IMP imp = class_getMethodImplementation(class, sel);
NSLog(@"%@-%p",NSStringFromSelector(sel),imp);
}
free(methodList);
}









网友评论