I want an image loading and caching library for iOS that
I've looked at HJCache, but it only satisfies the first two of these criteria. Is there something better?
Unfortunately, at this point, AsyncImage does not cache the images. This means the same image is downloaded again. Let's check out some code: In the code above, loadPhotos uses the async/await feature of Swift to perform and wait for the async tasks.
Image caching essentially means downloading an image to the local storage in the app's cache directory (or any other directory that is accessible to the app) and loading it from local storage next time the image loads.
An object that manages image data in your app.
I know that this thread has been answered, but I have tried a library that has worked great. I was using ASIHttpRequest before and the difference is big.
https://github.com/rs/SDWebImage
Also, if someone needs to Resize or Crop the remote images, and have the same features that SDWebImage provide, I have integrated SDWebImage library with UIImage+Resize library (by Trevor Harmon), and created an example project. I modified the code of SDWebImage to deal with transformations (crop, resize).
The project is public on https://github.com/toptierlabs/ImageCacheResize. Feel free to use it!
EDIT : ASI has been deprecated now but @Tony's answer has a link to a library that seems to do most of this (disclaimer - I've not yet tried it and am going by @Tony's recommendation!)
ASIHTTPRequest does all of that :)
All you would have to do is add something like to the 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've finished it, you could always pop it onto github for the rest of us . . .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With