From 4aeb7aca4e9b597697dacce949c71fb66efbcfed Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 10 Dec 2018 14:32:16 -0800 Subject: [PATCH] Move assertions so they are valid. (#1261) If PIN_ANIMATED is enabled, the creation of a PINRemoteImageManager will create a sharedDownloader also. Thus we cannot assert that it doesn't exist. We will move this assertion up to the methods that create the preconfiguredSharedManager and before said manager is allocated. --- Source/Details/ASPINRemoteImageDownloader.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Details/ASPINRemoteImageDownloader.mm b/Source/Details/ASPINRemoteImageDownloader.mm index 16a7795ba..35b1c919b 100644 --- a/Source/Details/ASPINRemoteImageDownloader.mm +++ b/Source/Details/ASPINRemoteImageDownloader.mm @@ -115,6 +115,7 @@ + (ASPINRemoteImageDownloader *)sharedDownloader NS_RETURNS_RETAINED + (void)setSharedImageManagerWithConfiguration:(nullable NSURLSessionConfiguration *)configuration { + NSAssert(sharedDownloader == nil, @"Singleton has been created and session can no longer be configured."); PINRemoteImageManager *sharedManager = [self PINRemoteImageManagerWithConfiguration:configuration imageCache:nil]; [self setSharedPreconfiguredRemoteImageManager:sharedManager]; } @@ -122,6 +123,7 @@ + (void)setSharedImageManagerWithConfiguration:(nullable NSURLSessionConfigurati + (void)setSharedImageManagerWithConfiguration:(nullable NSURLSessionConfiguration *)configuration imageCache:(nullable id)imageCache { + NSAssert(sharedDownloader == nil, @"Singleton has been created and session can no longer be configured."); PINRemoteImageManager *sharedManager = [self PINRemoteImageManagerWithConfiguration:configuration imageCache:imageCache]; [self setSharedPreconfiguredRemoteImageManager:sharedManager]; } @@ -131,7 +133,6 @@ + (void)setSharedImageManagerWithConfiguration:(nullable NSURLSessionConfigurati + (void)setSharedPreconfiguredRemoteImageManager:(PINRemoteImageManager *)preconfiguredPINRemoteImageManager { NSAssert(preconfiguredPINRemoteImageManager != nil, @"setSharedPreconfiguredRemoteImageManager requires a non-nil parameter"); - NSAssert(sharedDownloader == nil, @"Singleton has been created and session can no longer be configured."); NSAssert1(sharedPINRemoteImageManager == nil, @"An instance of %@ has been set. Either configuration or preconfigured image manager can be set at a time and only once.", [[sharedPINRemoteImageManager class] description]); dispatch_once(&shared_init_predicate, ^{