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

# beginSheetModal(for:completionHandler:)

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

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

## 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 [`NSFileHandlingPanelOKButton`](/documentation/AppKit/NSFileHandlingPanelOKButton) if the user chose the OK button or [`NSFileHandlingPanelCancelButton`](/documentation/AppKit/NSFileHandlingPanelCancelButton) if the user chose the Cancel button.

## 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(_:)`](/documentation/AppKit/NSWindow/orderOut(_:)) method with the value `nil`.

---

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)