Merge pull request #2655 from rahul-malik/rmalik-nsurlsessionfix

Re-add NSURLSessionConfiguration support and fix crashes
This commit is contained in:
Adlai Holler 2016-11-23 16:09:57 -08:00 committed by GitHub
commit 479dd6740e

View File

@ -103,15 +103,10 @@ static ASPINRemoteImageDownloader *sharedDownloader = nil;
+ (void)setSharedImageManagerWithConfiguration:(nullable NSURLSessionConfiguration *)configuration
{
NSAssert(sharedDownloader == nil, @"Singleton has been created and session can no longer be configured.");
__unused PINRemoteImageManager *sharedManager = [[self class] sharedPINRemoteImageManagerWithConfiguration:configuration];
__unused PINRemoteImageManager *sharedManager = [self sharedPINRemoteImageManagerWithConfiguration:configuration];
}
- (PINRemoteImageManager *)sharedPINRemoteImageManager
{
return [self sharedPINRemoteImageManagerWithConfiguration:nil];
}
- (PINRemoteImageManager *)sharedPINRemoteImageManagerWithConfiguration:(NSURLSessionConfiguration *)configuration
+ (PINRemoteImageManager *)sharedPINRemoteImageManagerWithConfiguration:(NSURLSessionConfiguration *)configuration
{
static ASPINRemoteImageManager *sharedPINRemoteImageManager;
static dispatch_once_t onceToken;
@ -133,7 +128,8 @@ static ASPINRemoteImageDownloader *sharedDownloader = nil;
userInfo:nil];
@throw e;
}
sharedPINRemoteImageManager = [[ASPINRemoteImageManager alloc] initWithSessionConfiguration:configuration alternativeRepresentationProvider:self];
sharedPINRemoteImageManager = [[ASPINRemoteImageManager alloc] initWithSessionConfiguration:configuration
alternativeRepresentationProvider:[self sharedDownloader]];
#else
sharedPINRemoteImageManager = [[ASPINRemoteImageManager alloc] initWithSessionConfiguration:configuration];
#endif
@ -141,6 +137,11 @@ static ASPINRemoteImageDownloader *sharedDownloader = nil;
return sharedPINRemoteImageManager;
}
- (PINRemoteImageManager *)sharedPINRemoteImageManager
{
return [ASPINRemoteImageDownloader sharedPINRemoteImageManagerWithConfiguration:nil];
}
- (BOOL)sharedImageManagerSupportsMemoryRemoval
{
static BOOL sharedImageManagerSupportsMemoryRemoval = NO;