---
title: flushIfNeeded()
framework: appkit
role: symbol
role_heading: Instance Method
path: appkit/nswindow/flushifneeded()
---

# flushIfNeeded()

Flushes the window’s offscreen buffer to the screen if flushing is enabled and if the last flush() message had no effect because flushing was disabled.

## Declaration

```swift
func flushIfNeeded()
```

## Discussion

Discussion To avoid unnecessary flushing, use this method rather than flush() to flush an NSWindow object after flushing has been reenabled.

## 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)
- [menuChanged(_:)](appkit/nswindow/menuchanged(_:).md)
- [cacheImage(in:)](appkit/nswindow/cacheimage(in:).md)
- [restoreCachedImage()](appkit/nswindow/restorecachedimage().md)
- [discardCachedImage()](appkit/nswindow/discardcachedimage().md)
- [useOptimizedDrawing(_:)](appkit/nswindow/useoptimizeddrawing(_:).md)
- [init(windowRef:)](appkit/nswindow/init(windowref:).md)
