Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSCache's name property

What's the purpose of NSCache's name? The Apple docs only say that you can set/retrieve the name of the cache using this property. So, what is it used for?

like image 302
lbrndnr Avatar asked Feb 26 '12 06:02

lbrndnr


2 Answers

As far as I can tell, Foundation doesn't use it for anything—not even for the cache's description, which seems like a missed opportunity to me.

You can retrieve a cache's name yourself, but I can't think of a reason why you would be passing caches around within your application and might therefore not already know which one you're looking at.

So the answer, as of Lion, seems to be: Nothing.

like image 93
Peter Hosey Avatar answered Oct 23 '22 03:10

Peter Hosey


The singular usage seems to be differentiation of caches when cache:willEvictObject: gets called in the NSCacheDelegate. This way you could (for instance) have a single object handling logging of cache expirations for all of your NSCaches and still have useful log messages that told where the objects were being evicted from.

like image 31
camdez Avatar answered Oct 23 '22 02:10

camdez