美文网首页
17、Objective-c 运行时编程

17、Objective-c 运行时编程

作者: 十二月_9d09 | 来源:发表于2019-08-04 16:09 被阅读0次

    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);
    

    相关文章

      网友评论

          本文标题:17、Objective-c 运行时编程

          本文链接:https://www.haomeiwen.com/subject/ukdydctx.html