代码库> 其他> method swizzling封装成 C函数和 NSObject分类,使用非常简单
method swizzling封装成 C函数和 NSObject分类,使用非常简单
关注
上传者:12207480 分类:其他(Others)
查看次数:2654 下载次数:202
上传时间:2015-08-04 大小:16 B
TYSwizzleDemo  method swizzling easy to use,C Function and NSObject Categary

我已经把 method swizzling  封装成 C 函数 和 NSObject 分类 ,使用非常简单,demo附带测试

C Function



// exchange instance method
BOOL ty_swizzleInstanceMethod(Class aClass, SEL originalSel, SEL replacementSel);

// exchange class method
BOOL ty_swizzleClassMethod(Class aClass, SEL originalSel, SEL replacementSel);

// exchange method with IMP, and store orignal IMP
BOOL ty_swizzleMethodAndStoreIMP(Class aClass, SEL originalSel, IMP replacementIMP,IMP *orignalStoreIMP);

IMP  ty_swizzleMethodIMP(Class aClass, SEL originalSel, IMP replacementIMP);



测试环境:Xcode 6.2,iOS 6.0 以上

NSObject Categary



// exchange instance method
+ (BOOL)ty_swizzleMethodWithOrignalSel:(SEL)orignalSel replacementSel:(SEL)replacementSel;

// exchange class method
+ (BOOL)ty_swizzleClassMethodWithOrignalSel:(SEL)orignalSel replacementSel:(SEL)replacementSel;

// exchange method with IMP, and store orignal IMP
+ (BOOL)ty_swizzleMethodWithOrignalSel:(SEL)orignalSel replacementIMP:(IMP)replacementIMP orignalStoreIMP:(IMP *)orignalStoreIMP;

+ (IMP) ty_swizzleMethodWithOrignalSel:(SEL)orignalSel replacementIMP:(IMP)replacementIMP;




收藏
我来说两句
发表评论
您还没有登录!请登录注册
所有评论(0
提示
sina weixin mail 回到顶部