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

Merge pull request #256 from jasonnoahchoi/features/publicCachePath

Make cachePathForKey public [resolves #255]
Wei Wang 10 лет назад
Родитель
Сommit
55e9049b6a
1 измененных файлов с 12 добавлено и 5 удалено
  1. 12 5
      Sources/ImageCache.swift

+ 12 - 5
Sources/ImageCache.swift

@@ -604,6 +604,18 @@ extension ImageCache {
             })
         })
     }
+    
+    /**
+    Get the cache path for the key.
+    It is useful for projects with UIWebView or anyone that needs access to the local file path
+    
+    i.e. <img src='key'>
+    */
+    public func cachePathForKey(key: String) -> String {
+        let fileName = cacheFileNameForKey(key)
+        return (diskCachePath as NSString).stringByAppendingPathComponent(fileName)
+    }
+
 }
 
 // MARK: - Internal Helper
@@ -622,11 +634,6 @@ extension ImageCache {
         return NSData(contentsOfFile: filePath)
     }
     
-    func cachePathForKey(key: String) -> String {
-        let fileName = cacheFileNameForKey(key)
-        return (diskCachePath as NSString).stringByAppendingPathComponent(fileName)
-    }
-    
     func cacheFileNameForKey(key: String) -> String {
         return key.kf_MD5
     }