If a cache check is initiated, then canceled with cancelForDelegate: before a new cache check
is started with a different URL but the same delegate, the ongoing disk cache check would still
message the delegate despite being canceled by cancelForDelegate:. This is because it only
checked to see if the delegate was in the cacheDelegates array; it had been removed by
cancelForDelegate:, but added back by the new unrelated cache check. cacheURLs keeps track
of which specific URLs are actually requested by the delegate. If the URL from a completed
disk cache check does not match the delegate in cacheDelegates, the delegate is not messaged
(since we know that request was canceled).
This new optimization is currently disabled by default so you can test it and give us feedback.
To enable it, add #define ENABLE_SDWEBIMAGE_DECODER and to not forget to add SDWebImageDecoder class
to your projet.
Thanks to Adam Jernst (https://github.com/adamjernst) and James Tang (https://github.com/mystcolor)
for this great optimization. See https://github.com/rs/SDWebImage/pull/18 for more info.
The -cancelForDelegate: method was working for downloads but not local cache checks. Add some new machinery to keep track of pending cache requests and only message the delegate if it hasn't since requested cancellation.
As showing/hiding the network activity indicator could conflict with your own code (i.e. the lib may hide the indicator when your code would still do some network stuff), the show/hide of the indicator isn't performed by the lib directly but SDWebImageDownloadStartNotification and SDWebImageDownloadStopNotification notifications are posted instead.
This lets you handle the indicator visiblity by yourself. If you're lazy, you can use the SDNetworkActivityIndicator library (http://github.com/rs/SDNetworkActivityIndicator) to handle it automatically. Once added to your project, all you have to do is to import this lib in addition to the SDWebImage lib.
Note that you should then use SDNetworkActivityIndicator for all your network status indicator visibility changes in your code if you don't want conflicts to happen.