|
|
<div id="cnblogs_post_body">10.1 GET请求
10.2 XML解析
10.3 JSON解析
10.4 POST请求
10.1 GET请求
通过一个第三方提供的云服务,查询IP归属地:http://www.youdao.com/smartresult-xml/search.s?type=ip&q=218.241.121.186
它的返回格式是xml :

新建个例子:CSSimpleXML,设计原型:

编辑按钮事件:
<div class="cnblogs_code">- (IBAction)query:(id)sender { NSString* strUrl = [NSString stringWithFormat:@"http://www.youdao.com/smartresult-xml/search.s?type=ip&q=%@", ipText.text]; NSURL* url = [NSURL URLWithString:strUrl]; NSURLRequest* request = [[NSURLRequest alloc]initWithURL:url]; NSURLConnection* connection = [[NSURLConnection alloc]initWithRequest:request delegate:self]; [connection release]; [request release]; [activityIndicator startAnimating];} |
|