Ver código fonte

Merge pull request #256 from jasonnoahchoi/features/publicCachePath

Make cachePathForKey public [resolves #255]
Wei Wang 10 anos atrás
pai
commit
55e9049b6a
1 arquivos alterados com 12 adições e 5 exclusões
  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
 // MARK: - Internal Helper
@@ -622,11 +634,6 @@ extension ImageCache {
         return NSData(contentsOfFile: filePath)
         return NSData(contentsOfFile: filePath)
     }
     }
     
     
-    func cachePathForKey(key: String) -> String {
-        let fileName = cacheFileNameForKey(key)
-        return (diskCachePath as NSString).stringByAppendingPathComponent(fileName)
-    }
-    
     func cacheFileNameForKey(key: String) -> String {
     func cacheFileNameForKey(key: String) -> String {
         return key.kf_MD5
         return key.kf_MD5
     }
     }