你真的懂使用Runtime进行swizzle的最佳写法?
前言 runtime 的黑魔法很多人都一定听过,或者已经在使用了。但是,怎么swizzle方法才是最好呢? 一般写法 Method originalMethod = class_getInstanceMethod(aClass, originalSel); Method swizzleMethod = class_getInstanceMethod(aClass, swizzleSel); method_exchangeImplementations(originalMethod, swizzleMethod); 或者是下面这种方式,swizzle第二种写法: Method originalMethod = class_getInstanceMethod(aClass, originalSel); Method swizzleMethod = class_getInstanceMethod(aClass, swizzleSel); BOOL didAddMethod = class_addMethod(aClass, originalSel, method_getImplementat...