这个NSEtcHosts使用另一种实现方式,感谢Mattt Thompson。
这个NSEtcHosts为您提供了整个应用程序主机名称的管控。
因为这个库所有功能都基于NSURLRequest。
件事!AFNetworking, SDWebImage也可用。
PonyCui/NSEtcHosts使用NSURLRequest
、初始化方法交换。
这是一个原型,并不打算在生产环境中使用。在生产环境中使用是不安全的。为了安全,所有代码使用DEBUG宏来防止在生产环境中构建NSEtcHosts类。
将"src"文件添加到项目中,或'Pod NSEtcHosts'。
#import "NSEtcHosts.h"
#ifdef DEBUG
[NSEtcHosts addHost:@"www.github.com" ipAddress:@"210.38.111.228"];
#endif
NSURL *URL = [NSURL URLWithString:@"http://www.github.com"];
[webView loadRequest:[NSURLRequest requestWithURL:URL]];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.github.com"]];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
}];
NSEtcHosts遵循MIT许可证。有关更多信息,请参阅LICENSE文件。