给NSObject添加分类
加入代码
+(void)load{
Method method1 = class_getInstanceMethod(self.class, @selector(methodSignatureForSelector:));
Method method2 = class_getInstanceMethod(self.class, @selector(mymethodSignatureForSelector:));
method_exchangeImplementations(method1, method2);
Method method3 = class_getInstanceMethod(self.class, @selector(forwardInvocation:));
Method method4 = class_getInstanceMethod(self.class, @selector(myforwardInvocation:));
method_exchangeImplementations(method3, method4);
}
-(NSMethodSignature*)mymethodSignatureForSelector:(SEL)selector
{
NSMethodSignature *signature = [NSMethodSignature signatureWithObjCTypes:@encode(void)];
return signature;
}
- (void)myforwardInvocation:(NSInvocation *)invocation {
}
做法比较霸道
参考:https://www.jianshu.com/p/c89b2716d60d