Can someone briefly explain to me when I would need to use NSCache? I read the documentation and I don’t get it. Like, give me an example of a scenario where NSCache would be useful?
Thanks.
Can someone briefly explain to me when I would need to use NSCache? I
Share
It’s more or less just like a dictionary, with the following additional things (as mentioned by the docs):
You might use it if your application has lots of data that it needs to work with, but you can’t keep it all in memory. For example, if you had an app that pulled data from an SQL Lite database or a web service, you might store it in an NSCache after looking it up. Then, when you need it again, you can check the cache first and only need to hit the database if it isn’t in the cache. The main advantage in this scenario over using a regular dictionary is that if you put too much stuff in the cache and it starts to fill up memory, it will automatically discard things to free up memory for you.