TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jun 2015 |
SPMSupports SPM | ✗ |
Maintained by pixelink.
override func didReceiveMemoryWarning() {
PIImageCache.shared.allMemoryCacheDelete()
}
func applicationDidEnterBackground(application: UIApplication) {
PIImageCache.shared.oldDiskCacheDelete()
}
let url = NSURL(string: "http://place-hold.it/200x200")!
let image = url.getImageWithCache()
let url = NSURL(string: "http://place-hold.it/200x200")!
let imgView = UIImageView()
imgView.imageOfURL(url)
let url = NSURL(string: "http://place-hold.it/200x200")!
let cache = PIImageCache.shared
image = cache.get(url)!
let url = NSURL(string: "http://place-hold.it/200x200")!
let cache = PIImageCache.shared
cache.prefetch(url)
set id, callback image with the id.
useful for UITableViewCell
// example: code in cellForRowAtIndexPath
let url = NSURL(string: "http://lorempixel.com/200/200/" )!
let id = indexPath.row
cell.id = indexPath.row
PIImageCache.shared.getWithId(url, id: i) {
[weak self] id, image in
if id == cell.id {
cell.icon.image = image
}
}
let cache = PIImageCache.shared
var config = PIImageCache.Config()
config.maxMemorySum = 5
config.limitByteSize = 100 * 1024 // 100kB
cache.setConfig(config)
let url = NSURL(string: "http://place-hold.it/200x200")!
let image = cache.get(url)!