<!--
{
  "availability" : [
    "macOS: 10.9.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSAlert/beginSheetModal(for:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAlert(im)beginSheetModalForWindow:completionHandler:"
  },
  "title" : "beginSheetModal(for:completionHandler:)"
}
-->

# beginSheetModal(for:completionHandler:)

Runs the alert modally as a sheet attached to the specified window.

```
func beginSheetModal(for sheetWindow: NSWindow, completionHandler handler: ((NSApplication.ModalResponse) -> Void)? = nil)
```

## Parameters

`sheetWindow`

The window on which to display the sheet.

`handler`

The completion handler that gets called when the sheet’s modal session ends.

## Discussion

This method uses the `NSWindow` sheet methods to display the alert (for more information, see Managing Sheets). If the alert has an alert style of [`NSCriticalAlertStyle`](/documentation/AppKit/NSCriticalAlertStyle), it is presented as a critical sheet, which means that it can display on top of other sheets that might already be attached to the window. Otherwise, it is presented—or queued for presentation—as a standard sheet.

Note that [`orderOut(_:)`](/documentation/AppKit/NSWindow/orderOut(_:)) no longer needs to be called in the completion handler. If you don’t dismiss the alert, it will be done for you after the completion handler finishes.

---

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)