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

# shared

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

```
class var shared: NSApplication { get }
```

## Return Value

The shared application object.

## Discussion

This method also makes a connection to the window server and completes other initialization. Your program should invoke this method as one of the first statements in `main()`; this invoking is done for you if you create your application with Xcode. To retrieve the `NSApplication` instance after it has been created, use the global variable [`NSApp`](/documentation/AppKit/NSApp) or invoke this method.

## See Also

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

Starts the main event loop.

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

Terminates the receiver.



---

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)
