Where exactly do you invoke setCelllImageURL:?
If its in the tableview delegate method objectforcellatrow.. then i suppose it is the wrong place..
A simple solution is
Create a own ImageCache class (it will be handy in your future projects, as it has helped me a lot)
provide a request method to other classes
Use an queue internally to maintain and process the request,
the request should contain the url, the sender object(object responsible to received the image after loading) and some context info to return back to the caller...
process each request in a separate thread
once the request is processed(i.e. image is loaded) then inform the sender object along with context info
now store the image in the cache (either a mutable dictionary or array) through which you can fetch the image if requested in future..
you can check for the size of total images and keep a constraint on the total size of the cache
(Sender object in your case would be your UITableViewController or the appropriate class)
Hope that explains well..
|