发送http请求get方法

//获取网页html
        NSURL* url = [NSURL URLWithString:@"http://www.baidu.com"];
        NSMutableURLRequest* request = [NSMutableURLRequest new];
        [request setURL:url];
        [request setHTTPMethod:@"GET"];
        NSURLRequest* response;
        NSData* data = [NSURLConnection sendSynchronousRequest:request
                                             returningResponse:&response error:nil];
        NSString* strRet = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
         NSLog(strRet);    
         [strRet release];

  

感谢来访,共同学习!
原文地址:https://www.cnblogs.com/dingxiaowei/p/3216690.html