码迷,mamicode.com
首页 > 其他好文 > 详细

NSConnection_异步下载Block

时间:2015-09-22 21:50:25      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:

NSString * path = @"http://10.0.8.8/sns/my/user_list.php";
    
    NSURL * url = [NSURL URLWithString:path];
    
    NSURLRequest * request = [NSURLRequest requestWithURL:url];
    
    //发送异步请求
    //Queue 队列   线程
    //[NSOperationQueue mainQueue] 主线程
    //handler  程序处理  请求完成之后的处理block
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
       //response 响应  data请求回来的数据  connectionError错误信息
        
        //解析数据 存储模型
        id obj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"%@",obj);
        
    }];
    

 

NSConnection_异步下载Block

标签:

原文地址:http://www.cnblogs.com/konglei/p/4830525.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!