<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSCacheDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSCacheDelegate"
  },
  "title" : "NSCacheDelegate"
}
-->

# NSCacheDelegate

The delegate of an [`NSCache`](/documentation/Foundation/NSCache) object implements this protocol to perform specialized actions when an object is about to be evicted or removed from the cache.

```
protocol NSCacheDelegate : NSObjectProtocol
```

## Topics

### Responding to Object Eviction

[`-  cache:willEvictObject:`](/documentation/Foundation/NSCacheDelegate/cache(_:willEvictObject:))

Called when an object is about to be evicted or removed from the cache.

## Relationships

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)