码迷,mamicode.com
首页 > 移动开发 > 详细

iOS runtime exchange methods

时间:2017-08-03 12:34:44      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:nbsp   tcl   void   code   eth   method   runtime   ons   bsp   

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

标签:nbsp   tcl   void   code   eth   method   runtime   ons   bsp   

原文地址:http://www.cnblogs.com/KingQiangzi/p/7278881.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!