---
title: "cacheDisplay(in:to:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsview/cachedisplay(in:to:)"
---

# cacheDisplay(in:to:)

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

## Declaration

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

## Parameters

- `rect`: A rectangle defining the region to be drawn into bitmapImageRep.
- `bitmapImageRep`: An doc://com.apple.appkit/documentation/AppKit/NSBitmapImageRep object. For pixel-format compatibility, bitmapImageRep should have been obtained from doc://com.apple.appkit/documentation/AppKit/NSView/bitmapImageRepForCachingDisplay(in:).

## Discussion

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.

## See Also

### Drawing the View’s Content

- [updateLayer()](appkit/nsview/updatelayer().md)
- [draw(_:)](appkit/nsview/draw(_:).md)
- [clipsToBounds](appkit/nsview/clipstobounds.md)
- [canDrawConcurrently](appkit/nsview/candrawconcurrently.md)
- [visibleRect](appkit/nsview/visiblerect.md)
- [getRectsBeingDrawn(_:count:)](appkit/nsview/getrectsbeingdrawn(_:count:).md)
- [needsToDraw(_:)](appkit/nsview/needstodraw(_:).md)
- [wantsDefaultClipping](appkit/nsview/wantsdefaultclipping.md)
- [bitmapImageRepForCachingDisplay(in:)](appkit/nsview/bitmapimagerepforcachingdisplay(in:).md)
- [NSBorderType](appkit/nsbordertype.md)
