---
title: "openDocument(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsdocumentcontroller/opendocument(_:)"
---

# openDocument(_:)

An action method called by the Open menu command, it runs the modal Open panel and, based on the selected filenames, creates one or more NSDocument objects from the contents of the files.

## Declaration

```swift
@IBAction func openDocument(_ sender: Any?)
```

## Discussion

Discussion The method adds the newly created objects to the list of NSDocument objects managed by the document controller. This method calls openDocument(withContentsOf:display:completionHandler:), which actually creates the NSDocument objects.

## See Also

### Responding to Action Messages

- [newDocument(_:)](appkit/nsdocumentcontroller/newdocument(_:).md)
- [saveAllDocuments(_:)](appkit/nsdocumentcontroller/savealldocuments(_:).md)
