So the NSCache object should stay alive in order to keep the cached data, that means the same object that was used to store data, has to be used to retrieve data.
- So the question is what’s the point of using NSCache over a singleton NSDictionary that holds my data?
- What’s the preferred way to use NSCache? static field? inherit it and create a singleton?
A cache has a number of quirks that make it work well as a cache while being poorly suited to use as a general purpose collection. As noted in the docs: