ohho
ohho

Reputation: 51941

Which image caching library for iOS?

I am building a photo album app and find a few image caching libraries, namely:

What one you'd recommend (or other libs not on the list)? I am looking for:

Thanks

Upvotes: 17

Views: 18009

Answers (7)

Ishwar Hingu
Ishwar Hingu

Reputation: 560

Moa

Moa is an image download library written in Swift. It allows to download and show an image in an image view by setting its moa.url property.

Installation Use CocoaPods to add Moa to your project. Just add the following line to your Podfile.

pod 'moa', '~> 8.0'

Upvotes: 0

Vinoth
Vinoth

Reputation: 9734

I strongly recommend you to try Kingfisher and SDWebImage. Both works perfectly for downloading and caching images from the web.

Upvotes: 0

kean
kean

Reputation: 1561

There are multiple frameworks that solve this problem. Just to name a few:

Swift:

Objective-C:

Upvotes: 6

slatvick
slatvick

Reputation: 1207

Try also APSmartStorage. It automatically caches UIImage/NSData on disk or in memory.

It has cute Blocks–style API;

    // setup data parsing block
APSmartStorage.sharedInstance.parsingBlock = ^(NSData *data, NSURL *url)
{
    return [UIImage imageWithData:data scale:UIScreen.mainScreen.scale];
};
...
// show some progress/activity
...
// load object with URL
[APSmartStorage.sharedInstance loadObjectWithURL:imageURL callback:(id object, NSError *error)
{
    // hide progress/activity
    if (error)
    {
        // show error
    }
    else 
    {
        // do something with object
    }
}];

It's quite smart and still simple:

enter image description here

Upvotes: 2

Abhijit
Abhijit

Reputation: 981

I tried using SDWebImage.

Agreed that it is very easy to integrate.

However the big issue with this library is that it does not honour "max-age" cache control.

The library is still under development but they are not picking this limitation.

Upvotes: 0

Alex Coplan
Alex Coplan

Reputation: 13371

Personally, I think SDWebImage is the best because it is an absolute no-effort solution, and provides the simplest mechanism for cache handling as it is simply an extension of the UIImageView class.

Upvotes: 18

rjgonzo
rjgonzo

Reputation: 1761

Image async downloading and caching is not a simple task. It needs to be done well otherwise it will defeat its purpose. Therefore I strongly suggest that eventually you build your own. Having said that, I needed a quick and simple solution in order to move forward with the development of my application.

I found these solutions:

I tried HJCache, but it didn't offer great scrolling performance when handling large images (1.5M+). For small images it worked great though. Tried both LazyTableImages as well but the integration wasn't simple.

Ultimately, I chose SDWebImage. The integration couldn't be simpler. Once you have linked the library to your project all you need to do is:

[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
               placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

in your tableView:cellForRowAtIndexPath:.

Additionally:

  • Works with custom cells as well
  • Doesn't block the UI
  • Offers great scrolling performance
  • Image downloading and caching is seamless.

Upvotes: 11

Related Questions