# NSCache class documentation

csdavec@swan.ac.uk
Generated at 2025-12-02 21:52:00 +0000
2009 Free Software Foundation, Inc.
Software documentation for the NSCache class
Foundation/NSCache.h
Description forthcoming.
countLimit
Returns the maximum number of objects that are supported by this cache.
delegate
Returns the cache's delegate.
evictsObjectsWithDiscardedContent
Returns whether objects stored in this cache which implement the NSDiscardableContent protocol are removed from the cache when their contents are evicted.
name
Returns the name associated with this cache.
objectForKey:
key
Returns an object associated with the specified key in this cache.
removeAllObjects
Removes all objects from this cache.
removeObjectForKey:
key
Removes the object associated with the given key.
setCountLimit:
lim
Sets the maximum number of objects permitted in this cache. This limit is advisory; caches may choose to disregard it temporarily or permanently. A limit of 0 is used to indicate no limit; this is the default.
setDelegate:
del
Sets the delegate for this cache. The delegate will be notified when an object is being evicted or removed from the cache.
setEvictsObjectsWithDiscardedContent:
b
Sets whether this cache will evict objects that conform to the NSDiscardableContent protocol, or simply discard their contents.
setName:
cacheName
Sets the name for this cache.
setObject:
obj
forKey:
key
Adds an object to the cache without associating a cost with it.
setObject:
obj
forKey:
key
cost:
num
Adds an object and its associated cost. The cache will endeavor to keep the total cost below the value set with -setTotalCostLimit: by discarding the contents of objects which implement the NSDiscardableContent protocol.
setTotalCostLimit:
lim
Sets the maximum total cost for objects stored in this cache. This limit is advisory; caches may choose to disregard it temporarily or permanently. A limit of 0 is used to indicate no limit; this is the default.
totalCostLimit
Returns the total cost of all objects held in the cache.
Software documentation for the NSCacheDelegate protocol
Foundation/NSCache.h
Protocol implemented by NSCache delegate objects.
cache:
cache
willEvictObject:
obj
Delegate method, called just before the cache removes an object, either as the result of user action or due to the cache becoming full.