Просмотр исходного кода

Merge pull request #823 from SlinToWin/master

Add option to remove image only from disk cache and not memory
Wei Wang 8 лет назад
Родитель
Сommit
0ffd946ba7
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      Sources/ImageCache.swift

+ 7 - 2
Sources/ImageCache.swift

@@ -234,16 +234,21 @@ open class ImageCache {
     - parameter key:               Key for the image.
     - parameter identifier:        The identifier of processor used. If you are using a processor for the image, pass the identifier of processor to it.
                                    This identifier will be used to generate a corresponding key for the combination of `key` and processor.
-    - parameter fromDisk:          Whether this image should be removed from disk or not. If false, the image will be only removed from memory.
+    - parameter fromMemory:        Whether this image should be removed from memory or not. If false, the image won't be removed from memory.
+    - parameter fromDisk:          Whether this image should be removed from disk or not. If false, the image won't be removed from disk.
     - parameter completionHandler: Called when removal operation completes.
     */
     open func removeImage(forKey key: String,
                           processorIdentifier identifier: String = "",
+                          fromMemory: Bool = true,
                           fromDisk: Bool = true,
                           completionHandler: (() -> Void)? = nil)
     {
         let computedKey = key.computedKey(with: identifier)
-        memoryCache.removeObject(forKey: computedKey as NSString)
+
+        if fromMemory {
+            memoryCache.removeObject(forKey: computedKey as NSString)
+        }
         
         func callHandlerInMainQueue() {
             if let handler = completionHandler {