Which image caching library for iOS?

前端 未结 7 562
轮回少年
轮回少年 2021-01-30 09:32

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

  • JMImageCache
  • HJCache
  • SDWebImage

What one you\'d re

相关标签:
7条回答
  • 2021-01-30 10:06

    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.

    0 讨论(0)
  • 2021-01-30 10:14

    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.

    0 讨论(0)
  • 2021-01-30 10:16

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

    Swift:

    • Nuke (mine)
    • Kingfisher
    • AlamofireImage
    • HanekeSwift

    Objective-C:

    • AFNetworking
    • PINRemoteImage
    • YYWebImage
    • SDWebImage
    0 讨论(0)
  • 2021-01-30 10:17

    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

    0 讨论(0)
  • 2021-01-30 10:20

    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'

    0 讨论(0)
  • 2021-01-30 10:26

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

    0 讨论(0)
提交回复
热议问题