EDIT:
after reading the answers below and looking at all the guides i am now lost, i am too noob to figure it out.
i don’t want the coding done for me, i need some clear cut advice on how to set up a seperate thread and then reference it to my tableView.
Any tutorials for a NOOB?!?
this is the code i have set up for putting images into my tableView. All the images load but only when scrolling through the table.
How can this be stopped?
Any help would be appreciated.
NSString *userImage = [(Tweet*)[profile objectAtIndex:indexPath.row] profileImage];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:[(Tweet*)[profile objectAtIndex:indexPath.row] profileImage]]];
dict =[[NSMutableDictionary alloc]init];
//UIImage *retImage =[dict objectForKey:(@"%@", userImage)];
UIImage *retImage =[dict objectForKey:userImage];
dispatch_async(dispatch_get_main_queue(), ^{
if (!retImage) {
UIImage *profileImage=[UIImage imageWithData:imageData];
[dict setObject:profileImage forKey:userImage];
}
UIImage *retImage2 =[dict objectForKey:userImage];
photo.image = retImage2;
[imageData release];
});
Loading the images on a background thread is one option. The better alternative would be to use NSOperationQueue that autmagically handles the background threads.
Apple has provided a sample for the same.
Please have a look at Lazy Loading Of TableViewCells
I hope it helps 🙂
EDIT: If you dont know, or dont want to use threads, then there is another alternate for that. Check this out:
downloading-images-for-table-without-threads