I have a way to load images for a UITableViewCell in the background. I am using performSelectorInBackground. The problem is that these streams complete and load images, even if they no longer appear on the screen. This can be taxed on resources, especially when using scroll quickly and creating multiple cells. Images are quite small and are loaded from disk (sqlite db), not from the URL.
I put the code in a cell to check if this is the last displayed cell, and I do not upload the image if it is not. This works, but it still creates threads, even if the βexpensiveβ job of loading an image from disk is not performed, unless it is the very last cell.
The question is, what is the best way to handle this? Should I kill existing threads every time a UITableViewCell is reused? How can I kill streams called by performSelectorInBackground?
Any other suggestions on how to handle this are welcome.
source share