<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindow/flushIfNeeded()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWindow(im)flushWindowIfNeeded"
  },
  "title" : "flushIfNeeded()"
}
-->

# flushIfNeeded()

Flushes the window’s offscreen buffer to the screen if flushing is enabled and if the last [`flush()`](/documentation/AppKit/NSWindow/flush()) message had no effect because flushing was disabled.

```
func flushIfNeeded()
```

## Discussion

To avoid unnecessary flushing, use this method rather than [`flush()`](/documentation/AppKit/NSWindow/flush()) to flush an `NSWindow` object after flushing has been reenabled.

---

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)