Presents a nonmodal Open dialog that displays files that can be opened based on a list of UTIs.
SDK
- macOS 10.8+
Framework
- App
Kit
Declaration
func beginOpenPanel(_ openPanel: NSOpen Panel, forTypes inTypes: [String]?, completionHandler: @escaping (Int) -> Void)
Parameters
openPanel
The open panel to present.
inTypes
A list of file types that the user should be allowed to choose in the open panel.
completionHandler
The completion handler that runs when the user clicks the OK or Cancel button in the open panel.
The block takes the following parameter:
result
Either
NSOKButton
orNSCancel
, depending on which button the user pressed to dismiss the dialog.Button
Discussion
This method is called by open
and begin
to do the actual work. You typically do not call this method directly. You can override this method as needed to customize the Open panel or to alter the list of UTIs in the in
parameter.
You can also override this method if you to perform additional cleanup (for example, if you customized the open panel and need to tear down an accessory view). Your overridden implementation should call the underlying method on super
, passing a custom completion handler. That handler should do the additional cleanup work, and then should call the completion handler block that was provided by the caller.