---
title: "beginSheetModal(for:completionHandler:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nssavepanel/beginsheetmodal(for:completionhandler:)"
---

# beginSheetModal(for:completionHandler:)

Presents the panel as a sheet modal to the specified window.

## Declaration

```swift
func beginSheetModal(for window: NSWindow, completionHandler handler: @escaping (NSApplication.ModalResponse) -> Void)
```

```swift
func beginSheetModal(for window: NSWindow) async -> NSApplication.ModalResponse
```

## Parameters

- `window`: The window in which the panel will be presented.
- `handler`: The block called after the user dismisses the panel. The argument passed in will be doc://com.apple.appkit/documentation/AppKit/NSFileHandlingPanelOKButton if the user chose the OK button or doc://com.apple.appkit/documentation/AppKit/NSFileHandlingPanelCancelButton if the user chose the Cancel button.

## Discussion

Discussion Configure all the relevant properties of the panel before you call this method. The completion handler block runs after the user dismisses the panel, but while the panel may still be onscreen. If you need to dismiss the panel from the screen—for example, if the completion block displays an alert—close the panel by calling its orderOut(_:) method with the value nil.

## See Also

### Showing the Panel

- [begin(completionHandler:)](appkit/nssavepanel/begin(completionhandler:).md)
- [runModal()](appkit/nssavepanel/runmodal().md)
- [validateVisibleColumns()](appkit/nssavepanel/validatevisiblecolumns().md)
