- (IBAction)downLoadImage:(id)sender { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ NSString* url=@"http://pic2.nipic.com/20090413/60867_143033029_2.jpg"; NSData* data=[[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:url]]; UIImage* image=[[UIImage alloc]initWithData:data]; if (image!=nil) { dispatch_async(dispatch_get_main_queue(), ^{ self.iv.image=image; }); } else { NSLog(@"下载出错!"); } });}
运行结果