AFN中所使用的 '运行时' 的交换类的方法和给类动态增加方法

来源:互联网 发布:方德软件中心 编辑:程序博客网 时间:2024/05/22 01:51
static inline void af_swizzleSelector(Class theClass, SEL originalSelector, SEL swizzledSelector) {    Method originalMethod = class_getInstanceMethod(theClass, originalSelector);    Method swizzledMethod = class_getInstanceMethod(theClass, swizzledSelector);    method_exchangeImplementations(originalMethod, swizzledMethod);}
static inline BOOL af_addMethod(Class theClass, SEL selector, Method method) {    return class_addMethod(theClass, selector,  method_getImplementation(method),  method_getTypeEncoding(method));}
1 0