<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSApplicationDelegate/application(_:openFile:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSApplicationDelegate(im)application:openFile:"
  },
  "title" : "application(_:openFile:)"
}
-->

# application(_:openFile:)

Returns a Boolean value that indicates if the app opens the specified file.

```
@MainActor optional func application(_ sender: NSApplication, openFile filename: String) -> Bool
```

## Parameters

`sender`

The application object associated with the delegate.

`filename`

The name of the file to open.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the file was successfully opened or <doc://com.apple.documentation/documentation/Swift/false> if it was not.

## Discussion

Sent directly by `theApplication` to the delegate. The method should open the file `filename`, returning <doc://com.apple.documentation/documentation/Swift/true> if the file is successfully opened, and <doc://com.apple.documentation/documentation/Swift/false> otherwise. If the user started up the application by double-clicking a file, the delegate receives the [`application(_:openFile:)`](/documentation/AppKit/NSApplicationDelegate/application(_:openFile:)) message before receiving [`applicationDidFinishLaunching(_:)`](/documentation/AppKit/NSApplicationDelegate/applicationDidFinishLaunching(_:)). ([`applicationWillFinishLaunching(_:)`](/documentation/AppKit/NSApplicationDelegate/applicationWillFinishLaunching(_:)) is sent before [`application(_:openFile:)`](/documentation/AppKit/NSApplicationDelegate/application(_:openFile:)).)

---

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)