Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1923 from garrettmoon/shareMemoryCache
Browse files Browse the repository at this point in the history
Share ASDK's PINRemoteImage cache with default instance of PINRemoteI…
  • Loading branch information
maicki authored Jul 14, 2016
2 parents fd856fc + aaea4a4 commit f95790f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions AsyncDisplayKit/Details/ASPINRemoteImageDownloader.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#import <PINCache/PINCache.h>

#if PIN_ANIMATED_AVAILABLE

@interface ASPINRemoteImageDownloader () <PINRemoteImageManagerAlternateRepresentationProvider>

@end
Expand Down Expand Up @@ -68,6 +69,19 @@ - (BOOL)isDataSupported:(NSData *)data
@end
#endif

@interface ASPINRemoteImageManager : PINRemoteImageManager
@end

@implementation ASPINRemoteImageManager

//Share image cache with sharedImageManager image cache.
- (PINCache *)defaultImageCache
{
return [[PINRemoteImageManager sharedImageManager] cache];
}

@end

@implementation ASPINRemoteImageDownloader

+ (instancetype)sharedDownloader
Expand All @@ -82,7 +96,7 @@ + (instancetype)sharedDownloader

- (PINRemoteImageManager *)sharedPINRemoteImageManager
{
static PINRemoteImageManager *sharedPINRemoteImageManager = nil;
static ASPINRemoteImageManager *sharedPINRemoteImageManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{

Expand All @@ -102,9 +116,9 @@ - (PINRemoteImageManager *)sharedPINRemoteImageManager
userInfo:nil];
@throw e;
}
sharedPINRemoteImageManager = [[PINRemoteImageManager alloc] initWithSessionConfiguration:nil alternativeRepresentationProvider:self];
sharedPINRemoteImageManager = [[ASPINRemoteImageManager alloc] initWithSessionConfiguration:nil alternativeRepresentationProvider:self];
#else
sharedPINRemoteImageManager = [[PINRemoteImageManager alloc] initWithSessionConfiguration:nil];
sharedPINRemoteImageManager = [[ASPINRemoteImageManager alloc] initWithSessionConfiguration:nil];
#endif
});
return sharedPINRemoteImageManager;
Expand Down

0 comments on commit f95790f

Please sign in to comment.