diff --git a/SDWebImage/SDWebImageDownloaderConfig.h b/SDWebImage/SDWebImageDownloaderConfig.h index c4e3792c..9f702bd6 100644 --- a/SDWebImage/SDWebImageDownloaderConfig.h +++ b/SDWebImage/SDWebImageDownloaderConfig.h @@ -25,6 +25,7 @@ typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { /** Gets/Sets the default downloader config used for shared instance or initialization when it does not provide any downloader config. Such as `SDWebImageDownloader.sharedDownloader`. + @note You can modify the property on default downloader config, which can be used for later created downloader instance. The already created downloader instance does not get affected. @note You should not pass nil to this value. */ @property (nonatomic, class, nonnull) SDWebImageDownloaderConfig *defaultDownloaderConfig; diff --git a/SDWebImage/SDWebImageDownloaderConfig.m b/SDWebImage/SDWebImageDownloaderConfig.m index 1a9f0f88..2d9d6136 100644 --- a/SDWebImage/SDWebImageDownloaderConfig.m +++ b/SDWebImage/SDWebImageDownloaderConfig.m @@ -13,9 +13,10 @@ static SDWebImageDownloaderConfig * _defaultDownloaderConfig; @implementation SDWebImageDownloaderConfig + (SDWebImageDownloaderConfig *)defaultDownloaderConfig { - if (!_defaultDownloaderConfig) { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ _defaultDownloaderConfig = [SDWebImageDownloaderConfig new]; - } + }); return _defaultDownloaderConfig; }