方法欺骗 使用 runtime 进行两个方法的交换
+ (void)load {
//获取类方法
Method olld = class_getClassMethod([self class], @selector(URLWithString:));
Method new = class_getClassMethod([self class], @selector(AZ_URLWithString:));
//交换两个方法的实现
method_exchangeImplementations(olld, new);
}
+ (instancetype)AZ_URLWithString:(NSString *)str{
NSURL *url =[NSURL AZ_URLWithString:str];
if (!url) {
NSLog(@"交换方法");
}
return url;
}