清秋梧桐

导航

iOS网络通信基本步骤

//创建URL字符串

NSString *urlStr = @"http://localhost:8080/MyFirstServerForiOS/";

//通过字符串穿件URL

NSURL *url = [NSURL URLWithString:urlStr];

//创建一个请求,制定请求访问的地址。

NSURLRequest *request = [NSURLRequestrequestWithURL:url];

//创建一个连接,指定连接将要发起的请求 .

NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self];

 

[connection start];

posted on 2012-11-19 14:21  清秋梧桐  阅读(292)  评论(0编辑  收藏  举报