Mac Developer Library

Developer

Foundation Framework Reference NSCacheDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSCacheDelegate

Inheritance


Not Applicable

Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in OS X v10.6 and later.

The delegate of an NSCache object implements this protocol to perform specialized actions when an object is about to be evicted or removed from the cache.

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

    Declaration

    Swift

    optional func cache(_ cache: NSCache, willEvictObject obj: AnyObject)

    Objective-C

    - (void)cache:(NSCache *)cache willEvictObject:(id)obj

    Parameters

    cache

    The cache with which the object of interest is associated.

    obj

    The object of interest in the cache.

    Discussion

    It is not possible to modify cache from within the implementation of this delegate method.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.6 and later.