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.

This commit is contained in:
DreamPiggy 2018-04-17 19:28:41 +08:00
parent cb7d5288c3
commit 77426d127f
4 changed files with 4 additions and 18 deletions

View File

@ -13,11 +13,10 @@
@interface SDImageCacheConfig : NSObject <NSCopying>
/**
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

View File

@ -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;

View File

@ -24,11 +24,10 @@ typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) {
@interface SDWebImageDownloaderConfig : NSObject <NSCopying>
/**
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.

View File

@ -20,12 +20,6 @@ static SDWebImageDownloaderConfig * _defaultDownloaderConfig;
return _defaultDownloaderConfig;
}
+ (void)setDefaultDownloaderConfig:(SDWebImageDownloaderConfig *)defaultDownloaderConfig {
if (defaultDownloaderConfig) {
_defaultDownloaderConfig = defaultDownloaderConfig;
}
}
- (instancetype)init {
self = [super init];
if (self) {