+(void)load{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class=[self class];
SEL originalSel=@selector(viewWillAppear:);
SEL swizzledSel=@selector(swizzled_viewWillAppear:);
Method originalMethod=class_getInstanceMethod(class, originalSel);
Method swizzledMethod=class_getInstanceMethod(class, swizzledSel);
BOOL isAddMethod=class_addMethod(class, originalSel, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
if (isAddMethod) {
class_replaceMethod(class, swizzledSel, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
}else{
method_exchangeImplementations(originalMethod, swizzledMethod);
}
});
}
-(void)swizzled_viewWillAppear:(BOOL)animated{
[self swizzled_viewWillAppear:YES];
NSLog(@"黑魔法");
}
-(void)viewWillAppear:(BOOL)animated{
}