From 77426d127f405d2be960ad714fbf87ca371b0ccc Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Tue, 17 Apr 2018 19:28:41 +0800 Subject: [PATCH] Fix the default download config & cache config to readonly. You can modify the property of config, but not the override the default config instance itself. --- SDWebImage/SDImageCacheConfig.h | 5 ++--- SDWebImage/SDImageCacheConfig.m | 6 ------ SDWebImage/SDWebImageDownloaderConfig.h | 5 ++--- SDWebImage/SDWebImageDownloaderConfig.m | 6 ------ 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/SDWebImage/SDImageCacheConfig.h b/SDWebImage/SDImageCacheConfig.h index 2590fbbf..2d2e28ee 100644 --- a/SDWebImage/SDImageCacheConfig.h +++ b/SDWebImage/SDImageCacheConfig.h @@ -13,11 +13,10 @@ @interface SDImageCacheConfig : NSObject /** - Gets/Sets the default cache config used for shared instance or initialization when it does not provide any cache config. Such as `SDImageCache.sharedImageCache`. + Gets the default cache config used for shared instance or initialization when it does not provide any cache config. Such as `SDImageCache.sharedImageCache`. @note You can modify the property on default cache config, which can be used for later created cache instance. The already created cache instance does not get affected. - @note You should not pass nil to this value. */ -@property (nonatomic, class, nonnull) SDImageCacheConfig *defaultCacheConfig; +@property (nonatomic, class, readonly, nonnull) SDImageCacheConfig *defaultCacheConfig; /** * Whether or not to disable iCloud backup diff --git a/SDWebImage/SDImageCacheConfig.m b/SDWebImage/SDImageCacheConfig.m index 2b36ea51..71110ae6 100644 --- a/SDWebImage/SDImageCacheConfig.m +++ b/SDWebImage/SDImageCacheConfig.m @@ -23,12 +23,6 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week return _defaultCacheConfig; } -+ (void)setDefaultCacheConfig:(SDImageCacheConfig *)defaultCacheConfig { - if (defaultCacheConfig) { - _defaultCacheConfig = defaultCacheConfig; - } -} - - (instancetype)init { if (self = [super init]) { _shouldDisableiCloud = YES; diff --git a/SDWebImage/SDWebImageDownloaderConfig.h b/SDWebImage/SDWebImageDownloaderConfig.h index 8caf8d95..ca41767b 100644 --- a/SDWebImage/SDWebImageDownloaderConfig.h +++ b/SDWebImage/SDWebImageDownloaderConfig.h @@ -24,11 +24,10 @@ typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { @interface SDWebImageDownloaderConfig : NSObject /** - Gets/Sets the default downloader config used for shared instance or initialization when it does not provide any downloader config. Such as `SDWebImageDownloader.sharedDownloader`. + Gets 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; +@property (nonatomic, class, readonly, nonnull) SDWebImageDownloaderConfig *defaultDownloaderConfig; /** * The maximum number of concurrent downloads. diff --git a/SDWebImage/SDWebImageDownloaderConfig.m b/SDWebImage/SDWebImageDownloaderConfig.m index 869dbf1c..393d6e06 100644 --- a/SDWebImage/SDWebImageDownloaderConfig.m +++ b/SDWebImage/SDWebImageDownloaderConfig.m @@ -20,12 +20,6 @@ static SDWebImageDownloaderConfig * _defaultDownloaderConfig; return _defaultDownloaderConfig; } -+ (void)setDefaultDownloaderConfig:(SDWebImageDownloaderConfig *)defaultDownloaderConfig { - if (defaultDownloaderConfig) { - _defaultDownloaderConfig = defaultDownloaderConfig; - } -} - - (instancetype)init { self = [super init]; if (self) {