Avatar
Avatar
nanasi
@swift-6.0.3 import Foundation let cache = NSCache<NSNumber, NSNumber>() cache.countLimit = 2 cache.setObject(1, forKey: 1) cache.setObject(2, forKey: 2) cache.setObject(3, forKey: 3) print(cache.object(forKey: 1)) print(cache.object(forKey: 2)) print(cache.object(forKey: 3))
swift60 BOT 1/3/2025 1:42 PM
Optional(1) Optional(2) nil<stdin>:10:7: warning: expression implicitly coerced from 'NSNumber?' to 'Any' 8 | cache.setObject(3, forKey: 3) 9 |