+ (void)load {
/*
使用 dispatch_once 防止方法交换被多次调用
*/
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Method method1 = class_getInstanceMethod([self class], @selector(test1));
Method method2 = class_getInstanceMethod([self class], @selector(test2));
method_exchangeImplementations(method1, method2);
});
}
网友评论