The SDWebImage project provides a similar UIImageView category, but offers both in-memory (using NSCache) and on-disk (using NSFileManager) caching. I'd recommend just using that when you need to cache to disk.
The downside to this implementation is that your network requests won't go through your AFHTTPClient
subclass, so depending on what your needs are you might need to implement your own operation queue, authentication, etc. If you're just using it for something basic, like displaying avatar images in a table view, it should be fine.
If that downside bothers you, an alternate idea would be to use SDImageCache
(included in the SDWebImage
project) to cache the images, and download them yourself using AFNetworking.
Finally, note that AFNetworking has built-in support for NSURLCache
, and if you create one it will cache your images to disk. However, image caching is typically used for showing lots of images in a UIScrollView
, and NSURLCache
doesn't have good enough performance for smooth scrolling.