I’m developing an iPhone application where I have a bunch of images bundled with the app and also new images being downloaded and put in Documents dir. When I need them I don’t know if they are new or bundled so I made a simple helper class that checks it for me.
It works, but it’s slow. How can I speed it up? I know I need to cache the images that comes from Documents dir, but what would be the most effective way? The code is currently in no way optimized. Any help is appriciated, thanks.
Some hints:
docsDir(NSSearchPathForDirectoriesInDomains), store it in a instance variable (or if class method [like your case], store it in a static variable)+ (UIImage *)imageNamed:(NSString *)namein a background thread. When the images is loaded from NSData/Path, then inform your ViewController (performSelectorOnMainThread!) that the images was loaded in background and present then the image (this will avoid jerks massively).Take a look at SDWebImage… they to all the stuff i told you above.