iOS 之 后台下载,前台显示模式,双 block

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    //耗时的操作
    NSURL *url = [NSURL URLWithString:@""];
    NSData *data = [[[NSData alloc] initWithContentsOfURL:url autorelease];
    UIImage *image = [[[UIImage alloc] initWithData:data] autorelease];
    
    dispatch_async(dispatch_get_main_queue(),^{ 
        //更新界面 
        _imageView.image = image;
    }); 
});    

posted on 2015-12-23 19:03  大木哥  阅读(206)  评论(0编辑  收藏  举报

导航