GCD

线程
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSURL * url = [NSURL URLWithString:@"http://avatar.csdn.net/2/C/D/1_totogo2010.jpg"];
        NSData * data = [[NSData alloc] initWithContentsOfURL: url];
        UIImage *image = [UIImage imageWithData:data];    /// 异步线程下载
        
        if (data != nil) {
            dispatch_async(dispatch_get_main_queue(), ^{
                self.avatarImageView.image = image;     ///主线线程刷新UI
            });
        }
    
    });

你可能感兴趣的:(GCD)