diff --git a/AsyncDisplayKit.podspec b/AsyncDisplayKit.podspec index bdcdb556ce..9e146ed38d 100644 --- a/AsyncDisplayKit.podspec +++ b/AsyncDisplayKit.podspec @@ -59,7 +59,8 @@ Pod::Spec.new do |spec| spec.subspec 'PINRemoteImage' do |pin| pin.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) PIN_REMOTE_IMAGE=1' } - pin.dependency 'PINRemoteImage/iOS', '>= 3.0.0-beta.3' + pin.dependency 'PINRemoteImage/iOS', '>= 3.0.0-beta.4' + pin.dependency 'PINRemoteImage/PINCache' pin.dependency 'AsyncDisplayKit/Core' end diff --git a/AsyncDisplayKit/Details/ASPINRemoteImageDownloader.m b/AsyncDisplayKit/Details/ASPINRemoteImageDownloader.m index 241fb71810..6ae4a0437d 100644 --- a/AsyncDisplayKit/Details/ASPINRemoteImageDownloader.m +++ b/AsyncDisplayKit/Details/ASPINRemoteImageDownloader.m @@ -27,7 +27,7 @@ #import #import -#import +#import #if PIN_ANIMATED_AVAILABLE @@ -75,7 +75,7 @@ @implementation ASPINRemoteImageManager //Share image cache with sharedImageManager image cache. -- (PINCache *)defaultImageCache +- (id )defaultImageCache { return [[PINRemoteImageManager sharedImageManager] cache]; } @@ -124,6 +124,16 @@ return sharedPINRemoteImageManager; } +- (BOOL)sharedImageManagerSupportsMemoryRemoval +{ + static BOOL sharedImageManagerSupportsMemoryRemoval = NO; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedImageManagerSupportsMemoryRemoval = [[[self sharedPINRemoteImageManager] cache] respondsToSelector:@selector(removeObjectForKeyFromMemory:)]; + }); + return sharedImageManagerSupportsMemoryRemoval; +} + #pragma mark ASImageProtocols #if PIN_ANIMATED_AVAILABLE @@ -163,9 +173,11 @@ - (void)clearFetchedImageFromCacheWithURL:(NSURL *)URL { - PINRemoteImageManager *manager = [self sharedPINRemoteImageManager]; - NSString *key = [manager cacheKeyForURL:URL processorKey:nil]; - [[[manager cache] memoryCache] removeObjectForKey:key]; + if ([self sharedImageManagerSupportsMemoryRemoval]) { + PINRemoteImageManager *manager = [self sharedPINRemoteImageManager]; + NSString *key = [manager cacheKeyForURL:URL processorKey:nil]; + [[manager cache] removeObjectForKeyFromMemory:key]; + } } - (nullable id)downloadImageWithURL:(NSURL *)URL