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