iOS runtime exchange methods

Posted 魅影追风

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS runtime exchange methods相关的知识,希望对你有一定的参考价值。

void bd_exchangeInstanceMethod(Class aClass, SEL oldSEL, SEL newSEL);
void bd_exchageClassMethod(Class aClass, SEL oldSEL, SEL newSEL);

 

 

 

#import <objc/runtime.h>

void bd_exchangeInstanceMethod(Class aClass, SEL oldSEL, SEL newSEL)
{
    Method oldMethod = class_getInstanceMethod(aClass, oldSEL);
    assert(oldMethod);
    Method newMethod = class_getInstanceMethod(aClass, newSEL);
    assert(newMethod);
    method_exchangeImplementations(oldMethod, newMethod);
}

void bd_exchageClassMethod(Class aClass, SEL oldSEL, SEL newSEL)
{
    Method oldClsMethod = class_getClassMethod(aClass, oldSEL);
    assert(oldClsMethod);
    Method newClsMethod = class_getClassMethod(aClass, newSEL);
    assert(newClsMethod);
    method_exchangeImplementations(oldClsMethod, newClsMethod);
}

 

以上是关于iOS runtime exchange methods的主要内容,如果未能解决你的问题,请参考以下文章

安装exchange 2013报错解决方法

rabbitmq中,使用一个exchange和使用多个exchange,性能会有差别吗

iOS开发runtime学习:一:runtime简介与runtime的消息机制

关于iOS的runtime

iOS runtime探究: 从runtime开始深入weak实现机理

iOS~runtime理解 - (开发面试必备)