Issue #766
Need to use a class, best is to subclass from NSObject
let cache = NSCache<Key, UIImage>()
final class Key: NSObject {
override func isEqual(_ object: Any?) -> Bool {
guard let other = object as? Key else {
return false
}
return url == other.url
&& size == other.size
}
override var hash: Int {
return url.hashValue ^ Int(size.width) ^ Int(size.height)
}
let url: URL
let size: CGSize
init(url: URL, size: CGSize) {
self.url = url
self.size = size
}
}