NSConnection_异步下载Block

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);
        
    }];
    

 

posted on 2015-09-22 21:19  konglei  阅读(124)  评论(0编辑  收藏  举报

导航