//1.创建一个子线程,用来获取网络图片
[NSThread detachNewThreadSelector:@selector(downloadImage:) toTarget:self withObject: @”http://pic36.nipic.com/20131128/11748057_141932278338_2.jpg“];
//下载图片
-(void)downloadImage:(NSString*)imagePath{
//1.将网络资源转化成二进制(一个耗时操作)
NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:imagePath]];
//2.将二进制文件转化成图片
UIImage* image = [UIImage imageWithData:data];
//3.将图片传到主线程
//参数1:回调主线程后执行的操作
//参数2:loadImage:方法的实参
//参数3:是否等待loadImage:执行结束才执行后续代码
[self.XMImage performSelector:@selector(setImage:) onThread:[NSThread mainThread] withObject:image waitUntilDone:YES];
NSLog(@"呵呵");
}