緩存配置對象容诬,存儲緩存配置信息
.h
@property (assign, nonatomic) BOOL shouldDecompressImages;
這個屬性設(shè)置為yes伦泥,可以改善性能遥昧,但是會消耗大量內(nèi)存。當(dāng)你內(nèi)存吃緊crash的時候柴钻,設(shè)置為no究西。默認(rèn)是yes卦碾。
@property (assign, nonatomic) BOOL shouldDisableiCloud;
設(shè)置為yes饺饭,不使用iCloud云備份渤早,默認(rèn)為yes
@property (assign, nonatomic) BOOL shouldCacheImagesInMemory;
設(shè)置為yes,在內(nèi)存中緩存圖片瘫俊。默認(rèn)為yes
@property (assign, nonatomic) NSInteger maxCacheAge;
緩存最長的保存時間鹊杖,單位是秒悴灵,默認(rèn)是一周
@property (assign, nonatomic) NSUInteger maxCacheSize;
最大緩存,單位是字節(jié)
.m
復(fù)制代碼
- (instancetype)init {
if (self = [super init]) {
_shouldDecompressImages = YES;
_shouldDisableiCloud = YES;
_shouldCacheImagesInMemory = YES;
_maxCacheAge = kDefaultCacheMaxCacheAge;
_maxCacheSize = 0;
}
return self;
}
復(fù)制代碼
初始化設(shè)置
static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week
靜態(tài)常量長整型骂蓖。