Instance Method


Presents a nonmodal Open dialog that displays files that can be opened based on a list of UTIs.


- (void)beginOpenPanel:(NSOpenPanel *)openPanel forTypes:(NSArray<NSString *> *)inTypes completionHandler:(void (^)(NSInteger result))completionHandler;



The open panel to present.


A list of file types that the user should be allowed to choose in the open panel.


The completion handler that runs when the user clicks the OK or Cancel button in the open panel.

The block takes the following parameter:


Either NSOKButton or NSCancelButton, depending on which button the user pressed to dismiss the dialog.


This method is called by openDocument: and beginOpenPanelWithCompletionHandler: 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 inTypes 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.

See Also

Managing the Open Dialog

- beginOpenPanelWithCompletionHandler:

Presents an Open dialog and delivers the results to a completion handler as an array of URLs for the chosen files (or nil).

- runModalOpenPanel:forTypes:

Presents a modal Open dialog and limits selection to specific file types.


The directory path to be used as the starting point in the Open panel.

- URLsFromRunningOpenPanel

An array of URLs corresponding to the files selected in a running open panel.