4 用代劳的办法发送收集请求
留意:须要遵守协定:
- <nsurlconnectiondatadelegate></nsurlconnectiondatadelegate>
代劳办法发送,琅绫擎包含了设置代劳的三种方法
- #pragma mark - 代劳办法发送请求
- - (void)sendAsyncDelegate
- {
- //肯定请求路径
- NSURL *url = [NSURL URLWithString:@"http://120.25.226.186:32812/login?username=520it&pwd=520it&type=JSON"];
- //创建请求对象
- NSURLRequest *request = [NSURLRequest requestWithURL:url];
- //设置代劳
- //第一种设置代劳:
- [NSURLConnection connectionWithRequest:request delegate:self];
- //第二种设置代劳:
- NSURLConnection *connecttion1 = [[NSURLConnection alloc] initWithRequest:request delegate:self];
- //第三种设置代劳:
- NSURLConnection *connecttion2 = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
- [connecttion2 start];
- }
实现代劳中的办法
- #pragma mark - 代劳办法
- //请求掉败的时刻调用
- - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
- {
- NSLog(@"%s------%@",__func__,[NSThread currentThread]);
- }
- //接收响应头信息
- - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
推荐阅读
沙龙晃荡 | 3月31日 京东、微博、华为拭魅战专家与你合营商量容器技巧实践! 所谓边沿数据中间,指的就是:处于>>>详细阅读
本文标题:iOS开发3年只用5分钟搞定面试官
地址:http://www.17bianji.com/lsqh/40950.html
1/2 1