记得头文件里面#import <objc/runtime.h>
1 2 3 4 5 6 7 8 9 10 11 12
|
+ (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); }
|
近期评论