#import "NSURL+CheckURL.h"
#import <objc/message.h>
@implementation NSURL (CheckURL)
+ (void)load
{
// get methos name
Method urlMethod = class_getClassMethod([NSURL class], @selector(URLWithString:));
Method newUrlMethod = class_getClassMethod([NSURL class], @selector(new_URLWithString:));
// swap methods
method_exchangeImplementations(urlMethod, newUrlMethod);
}
+ (instancetype)new_URLWithString:(NSString *)URLString
{
NSURL *url = [NSURL dd_URLWithString:URLString];
if (!url) {
NSLog(@"url is nil");
}
return url;
}
@end