Skip to content

Commit

Permalink
Move assertions so they are valid. (#1261)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wiseoldduck authored and maicki committed Dec 10, 2018
1 parent 1d4b4c7 commit 5ae6547
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Source/Details/ASPINRemoteImageDownloader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,15 @@ + (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];
}

+ (void)setSharedImageManagerWithConfiguration:(nullable NSURLSessionConfiguration *)configuration
imageCache:(nullable id<PINRemoteImageCaching>)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];
}
Expand All @@ -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, ^{
Expand Down

0 comments on commit 5ae6547

Please sign in to comment.