<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSApplication",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSApplication"
  },
  "title" : "NSApplication"
}
-->

# NSApplication

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

```
class NSApplication
```

## Overview

Every app uses a single instance of [`NSApplication`](/documentation/AppKit/NSApplication) to control the main event loop, keep track of the app’s windows and menus, distribute events to the appropriate objects (that’s, itself or one of its windows), set up autorelease pools, and receive notification of app-level events. An [`NSApplication`](/documentation/AppKit/NSApplication) object has a delegate (an object that you assign) that’s notified when the app starts or terminates, is hidden or activated, should open a file selected by the user, and so forth. By setting the delegate and implementing the delegate methods, you customize the behavior of your app without having to subclass [`NSApplication`](/documentation/AppKit/NSApplication). In your app’s `main()` function, create the [`NSApplication`](/documentation/AppKit/NSApplication) instance by calling the [`shared`](/documentation/AppKit/NSApplication/shared) class method. After creating the application object, the `main()` function should load your app’s main nib file and then start the event loop by sending the application object a [`run()`](/documentation/AppKit/NSApplication/run()) message. If you create an Application project in Xcode, this `main()` function is created for you. The `main()` function Xcode creates begins by calling a function named `NSApplicationMain()`, which is functionally similar to the following:

```objc
void NSApplicationMain(int argc, char *argv[]) {
    [NSApplication sharedApplication];
    [NSBundle loadNibNamed:@"myMain" owner:NSApp];
    [NSApp run];
}
```

The [`shared`](/documentation/AppKit/NSApplication/shared) class method initializes the display environment and connects your program to the window server and the display server. The [`NSApplication`](/documentation/AppKit/NSApplication) object maintains a list of all the [`NSWindow`](/documentation/AppKit/NSWindow) objects the app uses, so it can retrieve any of the app’s [`NSView`](/documentation/AppKit/NSView) objects. The [`shared`](/documentation/AppKit/NSApplication/shared) method also initializes the global variable `NSApp`, which you use to retrieve the [`NSApplication`](/documentation/AppKit/NSApplication) instance. [`shared`](/documentation/AppKit/NSApplication/shared) only performs the initialization once. If you invoke it more than once, it returns the application object it created previously.

The shared [`NSApplication`](/documentation/AppKit/NSApplication) object performs the important task of receiving events from the window server and distributing them to the proper [`NSResponder`](/documentation/AppKit/NSResponder) objects. `NSApp` translates an event into an [`NSEvent`](/documentation/AppKit/NSEvent) object, then forwards the event object to the affected [`NSWindow`](/documentation/AppKit/NSWindow) object. All keyboard and mouse events go directly to the [`NSWindow`](/documentation/AppKit/NSWindow) object associated with the event. The only exception to this rule is if the Command key is pressed when a key-down event occurs; in this case, every [`NSWindow`](/documentation/AppKit/NSWindow) object has an opportunity to respond to the event. When a window object receives an [`NSEvent`](/documentation/AppKit/NSEvent) object from `NSApp`, it distributes it to the objects in its view hierarchy.

[`NSApplication`](/documentation/AppKit/NSApplication) is also responsible for dispatching certain Apple events received by the app. For example, macOS sends Apple events to your app at various times, such as when the app is launched or reopened. [`NSApplication`](/documentation/AppKit/NSApplication) installs Apple event handlers to handle these events by sending a message to the appropriate object. You can also use the <doc://com.apple.documentation/documentation/Foundation/NSAppleEventManager> class to register your own Apple event handlers. The [`applicationWillFinishLaunching(_:)`](/documentation/AppKit/NSApplicationDelegate/applicationWillFinishLaunching(_:)) method is generally the best place to do so. For more information on how events are handled and how you can modify the default behavior, including information on working with Apple events in scriptable apps, see [How Cocoa Applications Handle Apple Events](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_handle_AEs/SAppsHandleAEs.html#//apple_ref/doc/uid/20001239) in [Cocoa Scripting Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_intro/SAppsIntro.html#//apple_ref/doc/uid/TP40002164).

The [`NSApplication`](/documentation/AppKit/NSApplication) class sets up `@autorelease` block during initialization and inside the event loop—specifically, within its initialization (or [`shared`](/documentation/AppKit/NSApplication/shared)) and [`run()`](/documentation/AppKit/NSApplication/run()) methods. Similarly, the methods AppKit adds to <doc://com.apple.documentation/documentation/Foundation/Bundle> employ `@autorelease` blocks during the loading of nib files. These `@autorelease` blocks aren’t accessible outside the scope of the respective [`NSApplication`](/documentation/AppKit/NSApplication) and <doc://com.apple.documentation/documentation/Foundation/Bundle> methods. Typically, an app creates objects either while the event loop is running or by loading objects from nib files, so this lack of access usually isn’t a problem. However, if you do need to use Cocoa classes within the `main()` function itself (other than to load nib files or to instantiate [`NSApplication`](/documentation/AppKit/NSApplication)), you should create an `@autorelease` block to contain the code using the classes.

### The delegate and notifications

You can assign a delegate to your [`NSApplication`](/documentation/AppKit/NSApplication) object. The delegate responds to certain messages on behalf of the object. Some of these messages, such as [`application(_:openFile:)`](/documentation/AppKit/NSApplicationDelegate/application(_:openFile:)), ask the delegate to perform an action. Another message, [`applicationShouldTerminate(_:)`](/documentation/AppKit/NSApplicationDelegate/applicationShouldTerminate(_:)), lets the delegate determine whether the app should be allowed to quit. The [`NSApplication`](/documentation/AppKit/NSApplication) class sends these messages directly to its delegate.

[`NSApplication`](/documentation/AppKit/NSApplication) also posts notifications to the app’s default notification center. Any object may register to receive one or more of the notifications posted by [`NSApplication`](/documentation/AppKit/NSApplication) by sending the message <doc://com.apple.documentation/documentation/Foundation/NotificationCenter/addObserver(_:selector:name:object:)> to the default notification center (an instance of the `NSNotificationCenter` class). The delegate of [`NSApplication`](/documentation/AppKit/NSApplication) is automatically registered to receive these notifications if it implements certain delegate methods. For example, [`NSApplication`](/documentation/AppKit/NSApplication) posts notifications when it’s about to be done launching the app and when it’s done launching the app ([`willFinishLaunchingNotification`](/documentation/AppKit/NSApplication/willFinishLaunchingNotification) and [`didFinishLaunchingNotification`](/documentation/AppKit/NSApplication/didFinishLaunchingNotification)). The delegate has an opportunity to respond to these notifications by implementing the methods [`applicationWillFinishLaunching(_:)`](/documentation/AppKit/NSApplicationDelegate/applicationWillFinishLaunching(_:)) and [`applicationDidFinishLaunching(_:)`](/documentation/AppKit/NSApplicationDelegate/applicationDidFinishLaunching(_:)). If the delegate wants to be informed of both events, it implements both methods. If it needs to know only when the app is finished launching, it implements only [`applicationDidFinishLaunching(_:)`](/documentation/AppKit/NSApplicationDelegate/applicationDidFinishLaunching(_:)).

### System services

`NSApplication` interacts with the system services architecture to provide services to your app through the Services menu.

### Subclassing notes

You rarely should find a real need to create a custom `NSApplication` subclass. Unlike some object-oriented libraries, Cocoa doesn’t require you to subclass `NSApplication` to customize app behavior. Instead it gives you many other ways to customize an app. This section discusses both some of the possible reasons to subclass `NSApplication` and some of the reasons *not* to subclass `NSApplication`.

To use a custom subclass of `NSApplication`, send [`shared`](/documentation/AppKit/NSApplication/shared) to your subclass rather than directly to `NSApplication`. If you create your app in Xcode, you can accomplish this by setting your custom app class to be the principal class. In Xcode, double-click the app target in the Groups and Files list to open the Info window for the target. Then display the Properties pane of the window and replace “NSApplication” in the Principal Class field with the name of your custom class. The `NSApplicationMain` function sends [`shared`](/documentation/AppKit/NSApplication/shared) to the principal class to obtain the global app instance (`NSApp`)—which in this case will be an instance of your custom subclass of `NSApplication`.

> Important:
> Many AppKit classes rely on the `NSApplication` class and may not work properly until this class is fully initialized. As a result, you should not, for example, attempt to invoke methods of other AppKit classes from an initialization method of an `NSApplication` subclass.

#### Methods to override

Generally, you subclass `NSApplication` to provide your own special responses to messages that are routinely sent to the global app object (`NSApp`). `NSApplication` doesn’t have primitive methods in the sense of methods that you must override in your subclass. Here are four methods that are possible candidates for overriding:

- Override [`run()`](/documentation/AppKit/NSApplication/run()) if you want the app to manage the main event loop differently than it does by default. (This a critical and complex task, however, that you should only attempt with good reason).
- Override [`sendEvent(_:)`](/documentation/AppKit/NSApplication/sendEvent(_:)) if you want to change how events are dispatched or perform some special event processing.
- Override [`requestUserAttention(_:)`](/documentation/AppKit/NSApplication/requestUserAttention(_:)) if you want to modify how your app attracts the attention of the user (for example, offering an alternative to the bouncing app icon in the Dock).
- Override [`target(forAction:)`](/documentation/AppKit/NSApplication/target(forAction:)) to substitute another object for the target of an action message.

#### Special considerations

The global app object uses `@autorelease` blocks in its [`run()`](/documentation/AppKit/NSApplication/run()) method; if you override this method, you’ll need to create your own `@autorelease` blocks.

Do not override [`shared`](/documentation/AppKit/NSApplication/shared). The default implementation, which is essential to app behavior, is too complex to duplicate on your own.

#### Alternatives to subclassing

`NSApplication` defines numerous [Delegation](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/Delegation.html#//apple_ref/doc/uid/TP40008195-CH14) methods that offer opportunities for modifying specific aspects of app behavior. Instead of making a custom subclass of `NSApplication`, your app delegate may be able to implement one or more of these methods to accomplish your design goals. In general, a better design than subclassing `NSApplication` is to put the code that expresses your app’s special behavior into one or more custom objects called controllers. Methods defined in your controllers can be invoked from a small dispatcher object without being closely tied to the global app object.

## Topics

### Getting the shared app object

[`shared`](/documentation/AppKit/NSApplication/shared)

Returns the application instance, creating it if it doesn’t exist yet.

[`NSApp`](/documentation/AppKit/NSApp)

The global variable for the shared app instance.

### Managing the app’s behavior

[`delegate`](/documentation/AppKit/NSApplication/delegate)

The app delegate object.

[`NSApplicationDelegate`](/documentation/AppKit/NSApplicationDelegate)

A set of methods that manage your app’s life cycle and its interaction with common system services.

### Managing the event loop

[`nextEvent(matching:until:inMode:dequeue:)`](/documentation/AppKit/NSApplication/nextEvent(matching:until:inMode:dequeue:))

Returns the next event matching a given mask, or `nil` if no such event is found before a specified expiration date.

[`discardEvents(matching:before:)`](/documentation/AppKit/NSApplication/discardEvents(matching:before:))

Removes all events matching the given mask and generated before the specified event.

[`currentEvent`](/documentation/AppKit/NSApplication/currentEvent)

The last event object that the app retrieved from the event queue.

[`isRunning`](/documentation/AppKit/NSApplication/isRunning)

A Boolean value indicating whether the main event loop is running.

[`run()`](/documentation/AppKit/NSApplication/run())

Starts the main event loop.

[`finishLaunching()`](/documentation/AppKit/NSApplication/finishLaunching())

Activates the app, opens any files specified by the `NSOpen` user default, and unhighlights the app’s icon.

[`stop(_:)`](/documentation/AppKit/NSApplication/stop(_:))

Stops the main event loop.

[`sendEvent(_:)`](/documentation/AppKit/NSApplication/sendEvent(_:))

Dispatches an event to other objects.

[`postEvent(_:atStart:)`](/documentation/AppKit/NSApplication/postEvent(_:atStart:))

Adds a given event to the receiver’s event queue.

[`NSEventTrackingRunLoopMode`](/documentation/AppKit/NSEventTrackingRunLoopMode)

The mode set when tracking events modally, such as a mouse-dragging loop.

### Posting actions

[`tryToPerform(_:with:)`](/documentation/AppKit/NSApplication/tryToPerform(_:with:))

Dispatches an action message to the specified target.

[`sendAction(_:to:from:)`](/documentation/AppKit/NSApplication/sendAction(_:to:from:))

Sends the given action message to the given target.

[`target(forAction:)`](/documentation/AppKit/NSApplication/target(forAction:))

Returns the object that receives the action message specified by the given selector.

[`target(forAction:to:from:)`](/documentation/AppKit/NSApplication/target(forAction:to:from:))

Searches for an object that can receive the message specified by the given selector.

### Terminating the app

[`terminate(_:)`](/documentation/AppKit/NSApplication/terminate(_:))

Terminates the receiver.

[`reply(toApplicationShouldTerminate:)`](/documentation/AppKit/NSApplication/reply(toApplicationShouldTerminate:))

Responds to `NSTerminateLater` once the app knows whether it can terminate.

### Activating and deactivating the app

[Passing control from one app to another with cooperative activation](/documentation/AppKit/passing-control-from-one-app-to-another-with-cooperative-activation)

Request focus for your app, and coordinate passing control from one app to another.

[`activate()`](/documentation/AppKit/NSApplication/activate())

Activates the receiver app, if appropriate.

[`deactivate()`](/documentation/AppKit/NSApplication/deactivate())

Deactivates the receiver.

[`isActive`](/documentation/AppKit/NSApplication/isActive)

A Boolean value indicating whether this is the active app.

[`yieldActivation(to:)`](/documentation/AppKit/NSApplication/yieldActivation(to:))

Explicitly allows another app to make itself active.

[`yieldActivation(toApplicationWithBundleIdentifier:)`](/documentation/AppKit/NSApplication/yieldActivation(toApplicationWithBundleIdentifier:))

Explicitly allows another app to make itself active.

[`NSApplication.ActivationOptions`](/documentation/AppKit/NSApplication/ActivationOptions)

The following flags are for [`activate(options:)`](/documentation/AppKit/NSRunningApplication/activate(options:)).

### Managing relaunch on login

[`disableRelaunchOnLogin()`](/documentation/AppKit/NSApplication/disableRelaunchOnLogin())

Disables relaunching the app on login.

[`enableRelaunchOnLogin()`](/documentation/AppKit/NSApplication/enableRelaunchOnLogin())

Enables relaunching the app on login.

### Managing remote notifications

[`registerForRemoteNotifications()`](/documentation/AppKit/NSApplication/registerForRemoteNotifications())

Register for notifications sent by Apple Push Notification service (APNs).

[`unregisterForRemoteNotifications()`](/documentation/AppKit/NSApplication/unregisterForRemoteNotifications())

Unregister for notifications received from Apple Push Notification service.

[`enabledRemoteNotificationTypes`](/documentation/AppKit/NSApplication/enabledRemoteNotificationTypes)

The types of push notifications that the app accepts.

[`registerForRemoteNotifications(matching:)`](/documentation/AppKit/NSApplication/registerForRemoteNotifications(matching:))

Register to receive notifications of the specified types from a provider through the Apple Push Notification service.

[`isRegisteredForRemoteNotifications`](/documentation/AppKit/NSApplication/isRegisteredForRemoteNotifications)

A Boolean value indicating whether the app is registered with Apple Push Notification service (APNs).

[`NSApplication.RemoteNotificationType`](/documentation/AppKit/NSApplication/RemoteNotificationType)

These constants determine whether apps launched by remote notifications display a badge.

### Managing the app’s appearance

[`appearance`](/documentation/AppKit/NSApplication/appearance)

The appearance associated with the app’s windows.

[`effectiveAppearance`](/documentation/AppKit/NSApplication/effectiveAppearance)

The appearance that AppKit uses to draw the app’s interface.

[`currentSystemPresentationOptions`](/documentation/AppKit/NSApplication/currentSystemPresentationOptions)

The set of app presentation options that are currently in effect for the system.

[`presentationOptions`](/documentation/AppKit/NSApplication/presentationOptions-swift.property)

The presentation options that should be in effect for the system when this app is active.

[`NSApplication.PresentationOptions`](/documentation/AppKit/NSApplication/PresentationOptions-swift.struct)

Constants that control the presentation of the app, typically for fullscreen apps such as games or kiosks.

[`applicationShouldSuppressHighDynamicRangeContent`](/documentation/AppKit/NSApplication/applicationShouldSuppressHighDynamicRangeContent)

A boolean value indicating whether your application should suppress HDR content based on established policy.
Built-in AppKit components such as NSImageView will automatically behave correctly with HDR content. You should use this value in conjunction with notifications (`NSApplicationShouldBeginSuppressingHighDynamicRangeContentNotification` and `NSApplicationShouldEndSuppressingHighDynamicRangeContentNotification`) to suppress HDR content in your application when signaled to do so.

### Managing windows, panels, and menus

[App Windows](/documentation/AppKit/app-windows)

Show, hide, minimize, arrange, and update your app’s windows.

[Modal Windows and Panels](/documentation/AppKit/modal-windows-and-panels)

Display a modal window or show one of the standard app panels, such as the app’s About panel.

[Menus](/documentation/AppKit/menus)

Access the app’s main menu items and update the window and services menus.

### User interface layout direction

[`userInterfaceLayoutDirection`](/documentation/AppKit/NSApplication/userInterfaceLayoutDirection)

The layout direction of the user interface.

[`NSUserInterfaceLayoutDirection`](/documentation/AppKit/NSUserInterfaceLayoutDirection)

Specifies the directional flow of the user interface.

### Accessing the dock tile

[`dockTile`](/documentation/AppKit/NSApplication/dockTile)

The app’s Dock tile.

[`applicationIconImage`](/documentation/AppKit/NSApplication/applicationIconImage)

The image used for the app’s icon.

### Customizing the Touch Bar

[`toggleTouchBarCustomizationPalette(_:)`](/documentation/AppKit/NSApplication/toggleTouchBarCustomizationPalette(_:))

Show or hides the interface for customizing the Touch Bar.

### Managing user attention requests

[`requestUserAttention(_:)`](/documentation/AppKit/NSApplication/requestUserAttention(_:))

Starts a user attention request.

[`NSApplication.RequestUserAttentionType`](/documentation/AppKit/NSApplication/RequestUserAttentionType)

These constants specify the level of severity of a user attention request and are used by [`cancelUserAttentionRequest(_:)`](/documentation/AppKit/NSApplication/cancelUserAttentionRequest(_:)) and [`requestUserAttention(_:)`](/documentation/AppKit/NSApplication/requestUserAttention(_:)).

[`cancelUserAttentionRequest(_:)`](/documentation/AppKit/NSApplication/cancelUserAttentionRequest(_:))

Cancels a previous user attention request.

[`reply(toOpenOrPrint:)`](/documentation/AppKit/NSApplication/reply(toOpenOrPrint:))

Handles errors that might occur when the user attempts to open or print files.

[`NSApplication.DelegateReply`](/documentation/AppKit/NSApplication/DelegateReply)

Constants that indicate whether a copy or print operation was successful, was canceled, or failed.

### Providing help information

[`registerUserInterfaceItemSearchHandler(_:)`](/documentation/AppKit/NSApplication/registerUserInterfaceItemSearchHandler(_:))

Register an object that provides help data to your app.

[`searchString(_:inUserInterfaceItemString:range:found:)`](/documentation/AppKit/NSApplication/searchString(_:inUserInterfaceItemString:range:found:))

Searches for the string in the user interface.

[`unregisterUserInterfaceItemSearchHandler(_:)`](/documentation/AppKit/NSApplication/unregisterUserInterfaceItemSearchHandler(_:))

Unregister an object that provides help data to your app.

[`showHelp(_:)`](/documentation/AppKit/NSApplication/showHelp(_:))

If your project is properly registered, and the necessary keys have been set in the property list, this method launches Help Viewer and displays the first page of your app’s help book.

[`activateContextHelpMode(_:)`](/documentation/AppKit/NSApplication/activateContextHelpMode(_:))

Places the receiver in context-sensitive help mode.

[`helpMenu`](/documentation/AppKit/NSApplication/helpMenu)

The help menu used by the app.

### Providing services

[`validRequestor(forSendType:returnType:)`](/documentation/AppKit/NSApplication/validRequestor(forSendType:returnType:))

Indicates whether the receiver can send and receive the specified pasteboard types.

[`servicesProvider`](/documentation/AppKit/NSApplication/servicesProvider)

The object that provides the services the current app advertises in the Services menu of other apps.

### Determining access to the keyboard

[`isFullKeyboardAccessEnabled`](/documentation/AppKit/NSApplication/isFullKeyboardAccessEnabled)

A Boolean value indicating whether Full Keyboard Access is enabled in the Keyboard preference pane.

### Hiding apps

[`hideOtherApplications(_:)`](/documentation/AppKit/NSApplication/hideOtherApplications(_:))

Hides all apps, except the receiver.

[`unhideAllApplications(_:)`](/documentation/AppKit/NSApplication/unhideAllApplications(_:))

Unhides all apps, including the receiver.

### Managing threads

[`detachDrawingThread(_:toTarget:with:)`](/documentation/AppKit/NSApplication/detachDrawingThread(_:toTarget:with:))

Creates and executes a new thread based on the specified target and selector.

### Logging exceptions

[`reportException(_:)`](/documentation/AppKit/NSApplication/reportException(_:))

Logs a given exception by calling `NSLog()`.

### Configuring the activation policy

[`activationPolicy()`](/documentation/AppKit/NSApplication/activationPolicy())

Returns the app’s activation policy.

[`setActivationPolicy(_:)`](/documentation/AppKit/NSApplication/setActivationPolicy(_:))

Attempts to modify the app’s activation policy.

[`NSApplication.ActivationPolicy`](/documentation/AppKit/NSApplication/ActivationPolicy-swift.enum)

Activation policies (used by [`activationPolicy`](/documentation/AppKit/NSRunningApplication/activationPolicy)) that control whether and how an app may be activated.

### Scripting your app

[`orderedDocuments`](/documentation/AppKit/NSApplication/orderedDocuments)

An array of document objects arranged according to the front-to-back ordering of their associated windows.

[`orderedWindows`](/documentation/AppKit/NSApplication/orderedWindows)

An array of window objects arranged according to their front-to-back ordering on the screen.

### Notifications

These notifications apply to `NSApplication`. See Notifications in [`NSWorkspace`](/documentation/AppKit/NSWorkspace)

A workspace that can launch other apps and perform a variety of file-handling services. for additional, similar notifications.

[`didBecomeActiveNotification`](/documentation/AppKit/NSApplication/didBecomeActiveNotification)

Posted immediately after the app becomes active.

[`didChangeScreenParametersNotification`](/documentation/AppKit/NSApplication/didChangeScreenParametersNotification)

Posted when the configuration of the displays attached to the computer is changed.

[`didFinishLaunchingNotification`](/documentation/AppKit/NSApplication/didFinishLaunchingNotification)

Posted at the end of the [`finishLaunching()`](/documentation/AppKit/NSApplication/finishLaunching()) method to indicate that the app has completed launching and is ready to run.

[`didHideNotification`](/documentation/AppKit/NSApplication/didHideNotification)

Posted at the end of the [`hide(_:)`](/documentation/AppKit/NSApplication/hide(_:)) method to indicate that the app is now hidden.

[`didResignActiveNotification`](/documentation/AppKit/NSApplication/didResignActiveNotification)

Posted immediately after the app gives up its active status to another app.

[`didUnhideNotification`](/documentation/AppKit/NSApplication/didUnhideNotification)

Posted at the end of the [`unhideWithoutActivation()`](/documentation/AppKit/NSApplication/unhideWithoutActivation()) method to indicate that the app is now visible.

[`didUpdateNotification`](/documentation/AppKit/NSApplication/didUpdateNotification)

Posted at the end of the [`updateWindows()`](/documentation/AppKit/NSApplication/updateWindows()) method to indicate that the app has finished updating its windows.

[`willBecomeActiveNotification`](/documentation/AppKit/NSApplication/willBecomeActiveNotification)

Posted immediately before the app becomes active.

[`willFinishLaunchingNotification`](/documentation/AppKit/NSApplication/willFinishLaunchingNotification)

Posted at the start of the [`finishLaunching()`](/documentation/AppKit/NSApplication/finishLaunching()) method to indicate that the app has completed its initialization process and is about to finish launching.

[`willHideNotification`](/documentation/AppKit/NSApplication/willHideNotification)

Posted at the start of the [`hide(_:)`](/documentation/AppKit/NSApplication/hide(_:)) method to indicate that the app is about to be hidden.

[`willResignActiveNotification`](/documentation/AppKit/NSApplication/willResignActiveNotification)

Posted immediately before the app gives up its active status to another app.

[`willTerminateNotification`](/documentation/AppKit/NSApplication/willTerminateNotification)

Sends a notification to terminate the app.

[`willUnhideNotification`](/documentation/AppKit/NSApplication/willUnhideNotification)

Posted at the start of the [`unhideWithoutActivation()`](/documentation/AppKit/NSApplication/unhideWithoutActivation()) method to indicate that the app is about to become visible.

[`willUpdateNotification`](/documentation/AppKit/NSApplication/willUpdateNotification)

Posted at the start of the [`updateWindows()`](/documentation/AppKit/NSApplication/updateWindows()) method to indicate that the app is about to update its windows.

[`didFinishRestoringWindowsNotification`](/documentation/AppKit/NSApplication/didFinishRestoringWindowsNotification)

Posted when the app has finished restoring windows.

[`didChangeOcclusionStateNotification`](/documentation/AppKit/NSApplication/didChangeOcclusionStateNotification)

Posted when the app’s occlusion state changes.

[`NSApplicationProtectedDataDidBecomeAvailableNotification`](/documentation/AppKit/NSApplicationProtectedDataDidBecomeAvailableNotification)

Posted when protected data becomes available.

[`NSApplicationProtectedDataWillBecomeUnavailableNotification`](/documentation/AppKit/NSApplicationProtectedDataWillBecomeUnavailableNotification)

Posted when protected data is about to become unavailable.

### Loading Cocoa bundles

[`loadApplication()`](/documentation/AppKit/NSApplication/loadApplication())

[`NSApplicationLoad`](/documentation/AppKit/NSApplicationLoad)

Startup function to call when running Cocoa code from a Carbon application.

### Displaying high dynamic resolution (HDR) content

[`applicationShouldSuppressHighDynamicRangeContent`](/documentation/AppKit/NSApplication/applicationShouldSuppressHighDynamicRangeContent)

A boolean value indicating whether your application should suppress HDR content based on established policy.
Built-in AppKit components such as NSImageView will automatically behave correctly with HDR content. You should use this value in conjunction with notifications (`NSApplicationShouldBeginSuppressingHighDynamicRangeContentNotification` and `NSApplicationShouldEndSuppressingHighDynamicRangeContentNotification`) to suppress HDR content in your application when signaled to do so.

[`NSApplication.ShouldBeginSuppressingHighDynamicRangeContent`](/documentation/AppKit/NSApplication/ShouldBeginSuppressingHighDynamicRangeContent)

[`NSApplication.ShouldEndSuppressingHighDynamicRangeContent`](/documentation/AppKit/NSApplication/ShouldEndSuppressingHighDynamicRangeContent)

[`NSApplicationShouldBeginSuppressingHighDynamicRangeContentNotification`](/documentation/AppKit/NSApplicationShouldBeginSuppressingHighDynamicRangeContentNotification)

[`NSApplicationShouldEndSuppressingHighDynamicRangeContentNotification`](/documentation/AppKit/NSApplicationShouldEndSuppressingHighDynamicRangeContentNotification)

### Deprecated

Avoid using deprecated classes and protocols in your apps.

[Deprecated Symbols](/documentation/AppKit/nsapplication-deprecated-symbols)

Review symbols that are no longer supported, and find the replacements to use instead.



---

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)