---
title: "useOptimizedDrawing(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nswindow/useoptimizeddrawing(_:)"
---

# useOptimizedDrawing(_:)

Specifies whether the window is to optimize focusing and drawing when displaying its views.

## Declaration

```swift
func useOptimizedDrawing(_ flag: Bool)
```

## Parameters

- `flag`: If doc://com.apple.documentation/documentation/Swift/true, the window will optimize focusing and drawing for its views; if doc://com.apple.documentation/documentation/Swift/false, it will not, in which case, the window does not preserve the Z-ordering of overlapping views when an object explicitly sends doc://com.apple.appkit/documentation/AppKit/NSView/lockFocus() to a view and draws directly to it, instead of using the AppKit standard display mechanism.

## Discussion

Discussion The optimizations may prevent sibling subviews from being displayed in the correct order—which matters only if the subviews overlap. You should always set flag to true when there are no overlapping subviews within the window. The default is false.

## See Also

### Methods

- [gState()](appkit/nswindow/gstate().md)
- [canStoreColor()](appkit/nswindow/canstorecolor().md)
- [enableFlushing()](appkit/nswindow/enableflushing().md)
- [disableFlushing()](appkit/nswindow/disableflushing().md)
- [flush()](appkit/nswindow/flush().md)
- [flushIfNeeded()](appkit/nswindow/flushifneeded().md)
- [menuChanged(_:)](appkit/nswindow/menuchanged(_:).md)
- [cacheImage(in:)](appkit/nswindow/cacheimage(in:).md)
- [restoreCachedImage()](appkit/nswindow/restorecachedimage().md)
- [discardCachedImage()](appkit/nswindow/discardcachedimage().md)
- [init(windowRef:)](appkit/nswindow/init(windowref:).md)
