您的位置:首页 > 移动开发 > IOS开发

ios运行时替换函数

2013-04-10 13:11 106 查看


#include

void Swizzle(Class c, SEL origSEL, SEL newSEL)

{

Method origMethod = class_getInstanceMethod(c, origSEL);

Method newMethod = class_getInstanceMethod(c, newSEL);

if(class_addMethod(c, origSEL, method_getImplementation(newMethod), method_getTypeEncoding(newMethod)))

class_replaceMethod(c, newSEL, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));

else

method_exchangeImplementations(origMethod, newMethod);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: