CGD---1--开辟并发新线程
//填充数据
- (void)fillInfoWith:(MyClassStudentsData *)myClassStudentsData
{
self.myClassStudentsData = myClassStudentsData;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//耗时
NSURL *url = [NSURL URLWithString:myClassStudentsData.picUrl];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
if (image) {
dispatch_async(dispatch_get_main_queue(), ^{
//更新界面
self.headImageView.image = image;
self.nameLabel.text = myClassStudentsData.name;
});
}
});
if ([myClassStudentsData.name length] > 3) {
self.nameLabel.font = [UIFont systemFontOfSize:15];
}else
{
self.nameLabel.font = [UIFont systemFontOfSize:18];
}
}