1、Objective-c重要的特性是runtime(运行时),在头文件<objc/runtime.h>中能找到相关的方法,objc_getclass()和objc_copyMethodList()在获取私有api时可以使用
2、交换两个方法的实现,常用于unit test
Method method1 = class_getInstanceMethod(class1,selector(sel1));
Method method2 = class_getInstanceMethod(class2,selector(sel2));
method_exchangeImplementation(method1,method2);
网友评论