<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSBestDepth",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:@F@NSBestDepth"
  },
  "title" : "NSBestDepth"
}
-->

# NSBestDepth

Attempts to return a window depth adequate for the specified parameters.

```
extern NSWindowDepth NSBestDepth(NSColorSpaceName colorSpace, NSInteger bps, NSInteger bpp, BOOL planar, BOOL *exactMatch);
```

## Discussion

Returns a window depth deep enough for the given number of colors in `colorSpace`, bits per sample specified by `bps`, bits per pixel specified by `bpp`, and whether planar as specified by `planar`. Upon return, the variable pointed to by `exactMatch` is <doc://com.apple.documentation/documentation/Swift/true> if the window depth can accommodate all of the values specified by the parameters, <doc://com.apple.documentation/documentation/Swift/false> if it can’t.

Use this function to compute window depths. This function tries to accommodate all the parameters (match or better); if there are multiple matches, it gives the closest, with matching `colorSpace` first, then `bps`, then `planar`, then `bpp`. `bpp` is “bits per pixel”; 0 indicates default (same as the number of bits per plane, either `bps` or `bps` * [`numberOfColorComponents`](/documentation/AppKit/NSColorSpaceName/numberOfColorComponents)); other values may be used as hints to provide backing stores of different configuration; for instance, 8-bit color. The `exactMatch` parameter is optional and indicates whether all the parameters matched exactly.

---

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)