Instance Method

application(_:openFile:)

Tells the delegate to open a single file.

Declaration

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

Parameters

theApplication

The application object associated with the delegate.

filename

The name of the file to open.

Return Value

true if the file was successfully opened or false if it was not.

Discussion

Sent directly by theApplication to the delegate. The method should open the file filename, returning true if the file is successfully opened, and false otherwise. If the user started up the application by double-clicking a file, the delegate receives the application(_:openFile:) message before receiving applicationDidFinishLaunching(_:). (applicationWillFinishLaunching(_:) is sent before application(_:openFile:).)

See Also

Opening Files

func application(Any, openFileWithoutUI: String) -> Bool

Tells the delegate to open a file programmatically.

func application(NSApplication, openTempFile: String) -> Bool

Tells the delegate to open a temporary file.

func application(NSApplication, openFiles: [String])

Tells the delegate to open multiple files.

func applicationOpenUntitledFile(NSApplication) -> Bool

Tells the delegate to open an untitled file.

func applicationShouldOpenUntitledFile(NSApplication) -> Bool

Invoked immediately before opening an untitled file.