NSURL 的简单实用

- (void)viewDidLoad {

     [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

- (IBAction)btnClick:(id)sender {

    

    NSString *urlString=@"http://www.map.baidu.com";

    NSURL *url=[NSURL URLWithString:urlString];

    NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];

    [NSURLConnection connectionWithRequest:urlRequest delegate:self];

}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data

{

    [_receDate appendData:data];

}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection

{

    NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.map.baidu.com"]];

    [self.webView loadRequest:request];

}

原文地址:https://www.cnblogs.com/linximu/p/4414377.html