Protocol

NSApplicationDelegate

The NSApplicationDelegate protocol defines the methods that may be implemented by delegates of NSApplication objects.

Symbols

Launching Applications

func applicationWillFinishLaunching(Notification)

Sent by the default notification center immediately before the application object is initialized.

func applicationDidFinishLaunching(Notification)

Sent by the default notification center after the application has been launched and initialized but before it has received its first event.

Terminating Applications

func applicationShouldTerminate(NSApplication)

Sent to notify the delegate that the application is about to terminate.

func applicationShouldTerminateAfterLastWindowClosed(NSApplication)

Invoked when the user closes the last window the application has open.

func applicationWillTerminate(Notification)

Sent by the default notification center immediately before the application terminates.

Managing Active Status

func applicationWillBecomeActive(Notification)

Sent by the default notification center immediately before the application becomes active.

func applicationDidBecomeActive(Notification)

Sent by the default notification center immediately after the application becomes active.

func applicationWillResignActive(Notification)

Sent by the default notification center immediately before the application is deactivated.

func applicationDidResignActive(Notification)

Sent by the default notification center immediately after the application is deactivated.

Hiding Applications

func applicationWillHide(Notification)

Sent by the default notification center immediately before the application is hidden.

func applicationDidHide(Notification)

Sent by the default notification center immediately after the application is hidden.

func applicationWillUnhide(Notification)

Sent by the default notification center immediately after the application is unhidden.

func applicationDidUnhide(Notification)

Sent by the default notification center immediately after the application is made visible.

Managing Windows

func applicationWillUpdate(Notification)

Sent by the default notification center immediately before the application object updates its windows.

func applicationDidUpdate(Notification)

Sent by the default notification center immediately after the application object updates its windows.

func applicationShouldHandleReopen(NSApplication, hasVisibleWindows: Bool)

Sent by the application to the delegate prior to default behavior to reopen (rapp) AppleEvents.

Managing the Dock Menu

func applicationDockMenu(NSApplication)

Allows the delegate to supply a dock menu for the application dynamically.

Displaying Errors

func application(NSApplication, willPresentError: Error)

Sent to the delegate before the specified application presents an error message to the user.

Managing the Screen

func applicationDidChangeScreenParameters(Notification)

Sent by the default notification center when the configuration of the displays attached to the computer is changed (either programmatically or when the user changes settings in the Displays control panel).

Opening Files

func application(NSApplication, openFile: String)

Tells the delegate to open a single file.

func application(Any, openFileWithoutUI: String)

Tells the delegate to open a file programmatically.

func application(NSApplication, openTempFile: String)

Tells the delegate to open a temporary file.

func application(NSApplication, openFiles: [String])

Tells the delegate to open multiple files.

func applicationOpenUntitledFile(NSApplication)

Tells the delegate to open an untitled file.

func applicationShouldOpenUntitledFile(NSApplication)

Invoked immediately before opening an untitled file.

Printing

func application(NSApplication, printFile: String)

Sent when the user starts up the application on the command line with the -NSPrint option.

Handling Push Notifications

func application(NSApplication, didRegisterForRemoteNotificationsWithDeviceToken: Data)

Sent to the delegate when Apple Push Services successfully completes the registration process.

func application(NSApplication, didFailToRegisterForRemoteNotificationsWithError: Error)

Sent to the delegate when Apple Push Service cannot successfully complete the registration process.

func application(NSApplication, didReceiveRemoteNotification: [String : Any])

Sent to the delegate when a running application receives a remote notification.

Application Restorable State

func application(NSApplication, didDecodeRestorableState: NSCoder)

Tells the delegate the application has extracted its restorable state from a given archiver.

func application(NSApplication, willEncodeRestorableState: NSCoder)

Tells the delegate the application will encode any application state that was preserved between application launches.

Continuing User Activities

func application(NSApplication, willContinueUserActivityWithType: String)

Tells the delegate the user wants to continue an activity in your app.

func application(NSApplication, continue: NSUserActivity, restorationHandler: ([Any]) -> Void)

Tells the delegate that the data for continuing an activity is available.

func application(NSApplication, didUpdate: NSUserActivity)

Tells the delegate that the user activity object has been updated.

Occlusion State

func applicationDidChangeOcclusionState(Notification)

Tells the delegate the application’s occlusion state changed.

Relationships

Inherits From