AutorÃa | Ultima modificación | Ver Log |
//// ImageCache.swift// twogetskills//// Created by Efrain Yanez Recanatini on 3/9/22.//import UIKitprotocol ImageCache {subscript(_ url: URL) -> UIImage? { get set }}struct TemporaryImageCache: ImageCache {private let cache: NSCache<NSURL, UIImage> = {let cache = NSCache<NSURL, UIImage>()cache.countLimit = 100 // 100 itemscache.totalCostLimit = 1024 * 1024 * 600 // 600 MBreturn cache}()subscript(_ key: URL) -> UIImage? {get { cache.object(forKey: key as NSURL) }set { newValue == nil ? cache.removeObject(forKey: key as NSURL) : cache.setObject(newValue!, forKey: key as NSURL) }}}