Question

When I try to fetch the images in UITableView using NSURL
UIImage image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://mysite.com/mobile/abc.jpg]]];
my application get freezes until the images loaded. Also when I scroll the table it get images from the server again and scroll get stuck for some time.
I know this is happening because of downloading images synchronously from server.
Is there any solution so that I can download the image asynchronously from server and store it locally or in cache so that when table scrolls it did not get images again from server.

Thanks

Was it helpful?

Solution

Check out EGOImageLoading by enormego. Works just like UIImage (and caches images) but lets you load from HTTP asynchronously.

OTHER TIPS

You can create your own class which leverages NSURLConnection and it's various Asynchronous methods to load your images in the background and then have a callback to display it in the cell.

However, there are some excellent libraries which do exactly what you've described. HJCache is one i've used and recommend for this sole purpose

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top