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

# getRectsBeingDrawn(_:count:)

Returns by indirection a list of nonoverlapping rectangles that define the area the view is being asked to draw in [`draw(_:)`](/documentation/AppKit/NSView/draw(_:)).

```
func getRectsBeingDrawn(_ rects: UnsafeMutablePointer<UnsafePointer<NSRect>?>?, count: UnsafeMutablePointer<Int>?)
```

## Parameters

`rects`

On return, contains a list of nonoverlapping rectangles defining areas to be drawn in. The rectangles returned in `rects` are in the coordinate space of the view.

`count`

On return, the number of rectangles in the `rects` list.

## Discussion

An implementation of [`draw(_:)`](/documentation/AppKit/NSView/draw(_:)) can use this information to test whether objects or regions within the view intersect with the rectangles in the list, and thereby avoid unnecessary drawing that would be completely clipped away.

The [`needsToDraw(_:)`](/documentation/AppKit/NSView/needsToDraw(_:)) method gives you a convenient way to test individual objects for intersection with the area being drawn in [`draw(_:)`](/documentation/AppKit/NSView/draw(_:)). However, you may want to retrieve and directly inspect the rectangle list if this is a more efficient way to perform intersection testing.

You should send this message only from within a [`draw(_:)`](/documentation/AppKit/NSView/draw(_:)) implementation. The `aRect` parameter of [`draw(_:)`](/documentation/AppKit/NSView/draw(_:)) is the rectangle enclosing the returned list of rectangles; you can use it in an initial pass to reject objects that are clearly outside the area to be drawn.

---

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)