How to cache images only in disk using Kingfisher?

后端 未结 3 1377
梦毁少年i
梦毁少年i 2021-02-20 17:00

I am using Kingfisher library for downloading and caching images. I am facing some issues in the implementation:

  1. Are the images ca

3条回答
  •  被撕碎了的回忆
    2021-02-20 17:29

    If anyone looking for answer for downloading images explicitly and caching the same without using imageView the sample code is:

    ImageDownloader.default.downloadImage(with: imgUrl, retrieveImageTask: nil, options: [], progressBlock: nil) { (image, error, url, data) in
                        print("Downloaded Image: \(url)")
                        //cache image:
                        if let image =  image, let url = url {
                            ImageCache.default.store(image, forKey: url.absoluteString)
                        }
                    }
    

    reference: https://github.com/onevcat/Kingfisher/wiki/Cheat-Sheet

提交回复
热议问题