In my app I download images and insert them into a table view. In my case there could be several same images with identical URLs. To reduce the server overloa, I’d like to download each image only once. Is there built-in support for this? Or what is the best way to achieve my goal?
Share
Create a
NSMutableDictionaryand as you download an image and place it in the table view, add the URL as the key in the dictionary and the table view row as the value. Before you download an image, check to make sure that the dictionary doesn’t already contain the URL (if ([[dictionary allKeys] containsObject:url]). If it doesn’t, download the image. If it does, then grab the row number and make the empty row’s image the same as the image of the row in the dictionary.