<!--
{
  "availability" : [
    "macOS: 10.8.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSDocumentController/beginOpenPanel(_:forTypes:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDocumentController(im)beginOpenPanel:forTypes:completionHandler:"
  },
  "title" : "beginOpenPanel(_:forTypes:completionHandler:)"
}
-->

# beginOpenPanel(_:forTypes:completionHandler:)

Presents a nonmodal Open dialog that displays files you can open from a list of UTIs.

```
func beginOpenPanel(_ openPanel: NSOpenPanel, forTypes inTypes: [String]?, completionHandler: @escaping (Int) -> Void)
```

## Parameters

`openPanel`

The Open dialog to present.

`inTypes`

A list of file types that the user can choose from in the Open dialog.

`completionHandler`

The completion handler that runs when the user clicks the OK or Cancel button in the Open dialog.

    The block takes the following parameter:

- `result`: Either [`NSOKButton`](/documentation/AppKit/NSOKButton) or [`NSCancelButton`](/documentation/AppKit/NSCancelButton), depending on which button the user clicks to dismiss the dialog.

## Discussion

[`openDocument(_:)`](/documentation/AppKit/NSDocumentController/openDocument(_:)) and [`beginOpenPanel(completionHandler:)`](/documentation/AppKit/NSDocumentController/beginOpenPanel(completionHandler:)) call this method to do the actual work. You typically don’t call this method directly. Override this method as necessary to customize the Open dialog or to alter the list of UTIs in the `inTypes` parameter.

You can also override this method if you want to perform additional cleanup (for example, if you customize the Open dialog and need to tear down an accessory view). Your overridden implementation needs to call the underlying method on `super`, passing a custom completion handler. That handler does the additional cleanup work, and then calls the completion handler block that the caller provides.

---

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)