Load UITableView images in background Asynchronously ?

L

UIImageView *SponsorLogo = [[UIImageView alloc] initWithFrame:CGRectMake(15, 90, 40, 40)];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^(void)
{
NSData *data0 = [NSData dataWithContentsOfURL:[NSURL URLWithString:@“your_image_URL_Here”]];
UIImage *image = [UIImage imageWithData:data0];
dispatch_sync(dispatch_get_main_queue(), ^(void)
{
SponsorLogo.image = image;
});
});
[cell.contentView addSubview:SponsorLogo];

About the author

abdulgafar.nurbash
By abdulgafar.nurbash

Category