<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSView/cacheDisplay(in:to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSView(im)cacheDisplayInRect:toBitmapImageRep:"
  },
  "title" : "cacheDisplay(in:to:)"
}
-->

# cacheDisplay(in:to:)

Draws the specified area of the view, and its descendants, into a provided bitmap-representation object.

```
func cacheDisplay(in rect: NSRect, to bitmapImageRep: NSBitmapImageRep)
```

## Parameters

`rect`

A rectangle defining the region to be drawn into `bitmapImageRep`.

`bitmapImageRep`

An [`NSBitmapImageRep`](/documentation/AppKit/NSBitmapImageRep) object. For pixel-format compatibility, `bitmapImageRep` should have been obtained from [`bitmapImageRepForCachingDisplay(in:)`](/documentation/AppKit/NSView/bitmapImageRepForCachingDisplay(in:)).

## Discussion

You are responsible for initializing the bitmap to the desired configuration before calling this method. However, once initialized, you can reuse the same bitmap multiple times to refresh the cached copy of your view’s contents.

The bitmap produced by this method is transparent (that is, has an alpha value of 0) wherever the view and its descendants do not draw any content.

---

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)