|
|
@@ -12,7 +12,7 @@
|
|
|
|
|
|
## 整体流程
|
|
|
|
|
|
-上层API
|
|
|
+上层API
|
|
|
|
|
|
Catergory 发起网络请求
|
|
|
|
|
|
@@ -62,7 +62,7 @@ SDWebImageCombinedOperation 包含cacheOperation和loaderOperation.
|
|
|
|
|
|
|
|
|
|
|
|
-磁盘 存储 NSData 读取到内存中
|
|
|
+磁盘 存储 NSData 读取到内存中
|
|
|
|
|
|
NSData \-\> UIImage
|
|
|
|
|
|
@@ -72,7 +72,7 @@ decode解压成位图 (内存比较大、耗时 子线程)
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
@@ -154,6 +154,36 @@ SDWebImageCombinedOperation
|
|
|
|
|
|
### 面向协议
|
|
|
|
|
|
+SDWebImageManager.m 中的代码
|
|
|
+
|
|
|
+5.0前
|
|
|
+
|
|
|
+```
|
|
|
+- (nonnull instancetype)init {
|
|
|
+ SDImageCache *cache = [SDImageCache sharedImageCache];
|
|
|
+ SDWebImageDownloader *downloader = [SDWebImageDownloader sharedDownloader];
|
|
|
+ return [self initWithCache:cache downloader:downloader];
|
|
|
+}
|
|
|
+
|
|
|
+```
|
|
|
+
|
|
|
+5.x后
|
|
|
+```
|
|
|
+- (nonnull instancetype)init {
|
|
|
+ id<SDImageCache> cache = [[self class] defaultImageCache];
|
|
|
+ if (!cache) {
|
|
|
+ cache = [SDImageCache sharedImageCache];
|
|
|
+ }
|
|
|
+ id<SDImageLoader> loader = [[self class] defaultImageLoader];
|
|
|
+ if (!loader) {
|
|
|
+ loader = [SDWebImageDownloader sharedDownloader];
|
|
|
+ }
|
|
|
+ return [self initWithCache:cache loader:loader];
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
SDImageCache协议
|
|
|
@@ -296,13 +326,3 @@ manager 管理缓存、下载两个核心模块
|
|
|
|
|
|
|
|
|
我们通过增加一个新的适配器类来解决接口不兼容的问题,使得原本没有任何关系的类可以协同工作
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|