swizzlingMethod方法混写示例 发表于 2016-04-13 | 记得头文件里面#import <objc/runtime.h> 123456789101112+ (void)load { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ [self swizzlingMethod:@selector(executeQuery:) with:@selector(swizzling_executeQuery:)]; });}+ (void)swizzlingMethod:(SEL)selector1 with:(SEL)selector2 { Method originalMethod = class_getInstanceMethod([self class], selector1); Method swizzlingMethod = class_getInstanceMethod([self class], selector2); method_exchangeImplementations(originalMethod, swizzlingMethod);}