I suspect that the slowness comes from calling retrieveImageFromServer
, which lets me think that you are accessing the network. If that access is synchronous, as it seems from the fact that you are assigning the image in the same statement, than this is bound to be slow.
You should review your code and make it run on a separate thread or use asynchronous network access.
EDIT:
After your comment about using, dataWithContentsOfURL
, my above hypothesis is confirmed.
You can read this S.O. post about a way to download images asynchronously, or you might use any of various networking frameworks available out there.
Possibly, the easiest path forward is using SDWebImage, which is a class that offers async download for images, so you don´t have to bother yourself with thread management or NSURLConnection
:
Just #import the UIImageView+WebCache.h header, and call the
setImageWithURL:placeholderImage:
method from thetableView:cellForRowAtIndexPath:
UITableViewDataSource
method. Everything will be handled for you, from async downloads to caching management.