-(void)setImageWithURL:(NSURL *)url,
the method in AFNetworking described: “If the image is cached locally, the image is set immediately“, but it does not make me to set cache directory, so where it cache the image in? Or is it really cache the image?
AFNetworkingtakes advantage of the caching functionality already provided byNSURLCacheand any of its subclasses.Use Pete Steinberger’s fork of SDURLCache which provides disk caching, which is not otherwise implemented by
NSURLCacheoniOS.Note: as of
iOS5, this is no longer needed.NSURLCachenow properlycaches objects, as long as theCache-Controlheaderisset.You may find it useful to
set ignoreMemoryOnlyStoragePolicytoYESfor theSDURLCacheinstance, which will ensure that images will be cached to disk more consistently for offline use (which, as reported in the SDURLCache README, iOS 5 supports, but only for http, so it still remains a good option if you want to support iOS 4 or https)Refer AFNetworking-FAQ – Does AFNetworking have any caching mechanisms built-in? and also AFURLCache – disk cache for iOS links.