IOS - caching and loading images asynchronously

I need an image upload and caching library for iOS which

  • uploads images asynchronously,
  • caches images with custom cache size and LRU behavior,
  • checks if images are updated using HTTP HEAD,
  • does not cache anything in case of an error code or invalid image.

I looked at HJCache , but it only satisfies the first two of these criteria. Is there something better?

+43
ios caching iphone image
Feb 22 '11 at 12:37
source share
3 answers

I know that this thread was answered, but I tried the library, which worked great. I used to use ASIHttpRequest and the difference was big.

https://github.com/rs/SDWebImage

In addition, if someone needs to resize or crop deleted images and have the same functions that SDWebImage provides, I integrated the SDWebImage library with the UIImage + Resize library (by Trevor Harmon) and created a sample project. I modified the SDWebImage code to handle transformations (cropping, resizing).

The project is available at https://github.com/toptierlabs/ImageCacheResize . Feel free to use it!

+29
Oct 28 '12 at 14:40
source share

EDIT: ASI is now deprecated, but @Tony's answer has a link to a library that seems to do most of this (disclaimer - I haven't tried it yet and disagree with @Tony's recommendation!)




ASIHTTPRequest does it all :)

All you have to do is add something like a success callback

UIImage *image = [UIImage imageWithData:[request responseData]]; // If the image is nil ASIHTTPRequest will let you remove the data from the cache // but I can't remember off the top of my head how. Checkout the docs! 



EDIT

And when you're done, you can always put it on github for the rest of us.,

+25
Feb 22 2018-11-22T00:
source share

I recently looked at what you described - either a general data cache or image-oriented, and did not find much interest. Therefore, you may have to minimize it yourself to get all of these features.

There are various blog posts and things detailing things like http://davidgolightly.blogspot.com/2009/02/asynchronous-image-caching-with-iphone.html .

I assume you reviewed the Three20 library? I do not think this will cover your requirements.

+1
Feb 22 '11 at 13:17
source share



All Articles