首页 > 编程语言 > 详细

线程之间的通讯

时间:2016-04-24 21:22:04      阅读:197      评论:0      收藏:0      [点我收藏+]

- (IBAction)action:(id)sender {
    NSLog(@"begin%@",[NSDate date]);
    NSDate * begin =[NSDate date];
    NSData * dat =[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://img.tuku.cn/file_thumb/201501/m2015013000131833.jpg"]];
    self.imageview.image=[UIImage imageWithData:dat];
    NSLog(@"endn%@",[NSDate date]);
    NSDate * end =[NSDate date];
    NSLog(@"%f",[end timeIntervalSinceDate:begin]);
    CFTimeInterval  start =CFAbsoluteTimeGetCurrent();
    
    
    [self performSelectorInBackground:@selector(down) withObject:nil];
    
    
}

-(void)down
{
    NSData * dat =[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://b.hiphotos.baidu.com/zhidao/pic/item/1e30e924b899a9010d59b4f31f950a7b0308f583.jpg"]];
    NSLog(@"%@",[NSThread currentThread]);
    UIImage* image=[UIImage imageWithData:dat];
    //回到主线程
//    [self.imageview performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];
    [self.imageview performSelector:@selector(setImage:) onThread:[NSThread mainThread] withObject:image waitUntilDone:NO ];
}

线程之间的通讯

原文:http://www.cnblogs.com/xiezefeng/p/5428155.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!