ImageManager
public class ImageManager
Handle image download and cache stuff.
-
How soon the image cache will be expired.
Declaration
Swift
public var maxCacheAge = NSTimeInterval.infinity
-
Path of image cache.
Declaration
Swift
public static var cachePath: String
-
Singleton access.
Declaration
Swift
public class func sharedManager() -> ImageManager
Return Value
Instance of ImageManager
-
Write image to cache.
Declaration
Swift
public func write(key: String, image: UIImage?, done: ((Bool) -> Void)? = nil)
Parameters
key
Key.
image
Value.
done
Callback.
-
Fetch image from cache asynchronously.
Declaration
Swift
public func fetch(key: String, queryPolicy: CacheQueryPolicy = .Normal, done: (UIImage?) -> Void)
Parameters
key
Key.
queryPolicy
Query policy, see
CacheQueryPolicy
.done
Callback when done in main thread.
-
Download image by url.
Declaration
Swift
public func downloadImage(url: String, progress: ((Int64, Int64) -> Void)? = nil, done: (UIImage?, NSError?) -> Void) -> NSOperation
Parameters
url
Image url.
progress
Report downloading progress.
done
Callback when done in main thread.
-
Batch download images.
Declaration
Swift
public func downloadImages(urls: [String], done: ([UIImage?]) -> Void)
Parameters
urls
Array of url.
done
Compeletion handler in main thread.
-
Download image but first look up in cache.
Declaration
Swift
public func downloadImageRespectCache(url: String, done: (UIImage?, NSError?) -> Void)
Parameters
url
Key.
done
Callback when done in main thread.
-
Cancel downoading operations.
Declaration
Swift
public func cancelAllOperations()
-
Clear memory cache.
Declaration
Swift
public func purgeMemory()
-
Clear disk cache.
Declaration
Swift
public func cleanDisk()
-
Clear memory and disk cache.
Declaration
Swift
public func clearCache()