2

I'm already using AFNetworking for async image download. I was wondering if there's a way for storing on disk or Core Data, should I investigate SDWebImage for that? Or you would suggest to have a custom solution. Basically I would like to have a very transparent way to get images from a url, so first look for them in a NSCache, if not found look on disk (or Core Data)l if not found again download async. Thanks for any idea

Emanuele Fumagalli
  • 1,476
  • 2
  • 19
  • 31
  • Not exactly a duplicate question, but same answers here: http://stackoverflow.com/questions/1130089/lazy-load-images-in-uitableview – Oded Ben Dov Jun 25 '12 at 07:15
  • SDWebImage is very convenient especially with the progressive image download. But it’s based out of **NSUrlConnection** ( even in the latest version 3.7.5 ) and we know that that is deprecated starting iOS 9. NSUrlSession has been around for 3+ years now and I think the future winner would be the one that implements NSUrlSession. **AFNetworking 3.0** is completely based on NSURLSession. So I think Afnetworking would a better choice than SDWebImage. – Utsav Dusad May 07 '16 at 06:31

3 Answers3

2

SDWebImage has proven to be a really solid implementation of async image fetching and caching.

If you're using your web images for buttons or imageviews you can even call the -(void)setImageWithURL:(NSURL *)url methods that will check the cache, get the image for you and if it's not there, it will async download it and store it in the cache before setting it.

If you need the images for some other stuff, you can still benefit from this library by calling :

SDWebImageManager *manager = [SDWebImageManager sharedManager];

// Remove in progress downloader from queue
[manager cancelForDelegate:self];

[manager downloadWithURL:yourURL delegate:self options:0];

and retrieving the image later on the delegate method:

- (void)webImageManager:(SDWebImageManager *)imageManager didFinishWithImage:(UIImage *)image
{
    // Do something with the image
}

Note that

- (void)downloadWithURL:(NSURL *)url delegate:(id<SDWebImageManagerDelegate>)delegate options:(SDWebImageOptions)options

does check the cache before attempting to download, so it is safe to call this every time you need an image.

Ignacio Inglese
  • 2,605
  • 16
  • 18
  • SDWebImage is based out of **NSUrlConnection** which is deprecated starting iOS 9. AFNetworking 3.0 uses NSURLSession. I think now the current choice would be AFNetworking! – Utsav Dusad May 07 '16 at 06:33
0

Give this a try...

https://github.com/rs/SDWebImage

craig1231
  • 3,769
  • 4
  • 31
  • 34
0

You could have a look to EGOImage which basically makes asynchronous calls and caching of images on the file system.

yeforriak
  • 1,705
  • 2
  • 18
  • 26