Protocol

NSApplicationDelegate

A set of methods that delegates of NSApplication objects can implement.

Declaration

@protocol NSApplicationDelegate

Topics

Launching Applications

- applicationWillFinishLaunching:

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

- applicationDidFinishLaunching:

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

Managing Active Status

- applicationWillBecomeActive:

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

- applicationDidBecomeActive:

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

- applicationWillResignActive:

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

- applicationDidResignActive:

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

Terminating Applications

- applicationShouldTerminate:

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

- applicationShouldTerminateAfterLastWindowClosed:

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

- applicationWillTerminate:

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

NSApplicationTerminateReply

Constants used by the delegate method applicationShouldTerminate: to determine whether an app should terminate.

Hiding Applications

- applicationWillHide:

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

- applicationDidHide:

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

- applicationWillUnhide:

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

- applicationDidUnhide:

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

Managing Windows

- applicationWillUpdate:

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

- applicationDidUpdate:

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

- applicationShouldHandleReopen:hasVisibleWindows:

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

Managing the Dock Menu

- applicationDockMenu:

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

Displaying Errors

- application:willPresentError:

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

Managing the Screen

- applicationDidChangeScreenParameters:

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).

Continuing User Activities

- application:willContinueUserActivityWithType:

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

- application:continueUserActivity:restorationHandler:

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

- application:didFailToContinueUserActivityWithType:error:

Tells the delegate that the activity could not be continued.

- application:didUpdateUserActivity:

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

Handling Push Notifications

- application:didRegisterForRemoteNotificationsWithDeviceToken:

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

- application:didFailToRegisterForRemoteNotificationsWithError:

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

- application:didReceiveRemoteNotification:

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

Handling CloudKit Invitations

- application:userDidAcceptCloudKitShareWithMetadata:

Tells the delegate that the user accepted a CloudKit sharing invitation associated with your app.

Opening Files

- application:openFile:

Tells the delegate to open a single file.

- application:openFileWithoutUI:

Tells the delegate to open a file programmatically.

- application:openTempFile:

Tells the delegate to open a temporary file.

- application:openFiles:

Tells the delegate to open multiple files.

- applicationOpenUntitledFile:

Tells the delegate to open an untitled file.

- applicationShouldOpenUntitledFile:

Invoked immediately before opening an untitled file.

Printing

- application:printFile:

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

NSApplicationPrintReply

Constants that are returned by the delegate method application:printFiles:withSettings:showPrintPanels:.

Restoring Application State

- application:didDecodeRestorableState:

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

- application:willEncodeRestorableState:

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

Handling Changes to the Occlusion State

- applicationDidChangeOcclusionState:

Tells the delegate the application’s occlusion state changed.

Relationships

Inherits From

See Also

Application

NSApplication

An object that manages an app’s main event loop and resources used by all of that app’s objects.

NSRunningApplication

An object that can manipulate and provide information for a single instance of an app.

NSApplicationMain

Called by the main function to create and run the application.