<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: 10.0.0 - 10.6.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSImage/setCacheDepthMatchesImageDepth:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSImage(im)setCacheDepthMatchesImageDepth:"
  },
  "title" : "setCacheDepthMatchesImageDepth:"
}
-->

# setCacheDepthMatchesImageDepth:

Sets whether the image’s offscreen window caches use the same bit depth as the image data itself.

```
- (void) setCacheDepthMatchesImageDepth:(BOOL) flag;
```

## Parameters

`flag`

<doc://com.apple.documentation/documentation/Swift/true> if the offscreen caches use the same bit-depth associated with the image data; otherwise, <doc://com.apple.documentation/documentation/Swift/false> to indicate they should use the default bit depth.

## Discussion

This method does not cause the receiver to recache itself. The default depth limit is equal to the bit depth of the deepest screen on the system.

## See Also

[`func recache()`](/documentation/AppKit/NSImage/recache())

Invalidates and frees offscreen caches of all image representations.

[`func lockFocus()`](/documentation/AppKit/NSImage/lockFocus())

Prepares the image to receive drawing commands.

[`- (BOOL) cacheDepthMatchesImageDepth;`](/documentation/AppKit/NSImage/cacheDepthMatchesImageDepth)

Returns a Boolean value that indicates whether an image’s offscreen window caches use the same bit depth as the image data itself.



---

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)