I'm downloading and saving some images from the web into my app's private storage to be displayed in tableview cells. I have it working, but unfortunately unless I'm using :
[UIImage imageNamed: @"filename"];
I don't get the built-in cache, and performance is slow. How can I implement my own image cache when using imageWithData
or imageWithContentsOfFile
?
I've seen more then a few discussions of this online over the years with various solutions and rationales. Arguably the simplest solution is here.
In short with large numbers of images, UIImage imageNamed
is rough on memory and it suggests using a simple dictionary with imageWithContentsOfFile
to store cached images where you can easily have more control over memory usage.