<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: 10.0.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSGetAlertPanel",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:@F@NSGetAlertPanel"
  },
  "title" : "NSGetAlertPanel"
}
-->

# NSGetAlertPanel

Returns an alert panel.

```
extern idNSGetAlertPanel(NSString *title, NSString *msgFormat, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);
```

## Discussion

Returns an [`NSPanel`](/documentation/AppKit/NSPanel) that can be used to set up a modal session. A modal session is useful for allowing the user to interrupt the program. During a modal session, you can perform activities while the panel is displayed and check at various points in your program whether the user has clicked one of the panel’s buttons. The arguments for this function are the same as those for [`NSRunAlertPanel`](/documentation/AppKit/NSRunAlertPanel), but unlike that function, no button is displayed if `defaultButton` is `nil`.

To set up a modal session, send the Application object [`beginModalSession(for:)`](/documentation/AppKit/NSApplication/beginModalSession(for:)) with the panel returned by [`NSGetAlertPanel`](/documentation/AppKit/NSGetAlertPanel) as its argument. When you want to check if the user has clicked one of the panel’s buttons, use [`runModalSession(_:)`](/documentation/AppKit/NSApplication/runModalSession(_:)). To end the modal session, use [`endModalSession(_:)`](/documentation/AppKit/NSApplication/endModalSession(_:)). When you’re finished with the panel created by [`NSGetAlertPanel`](/documentation/AppKit/NSGetAlertPanel), you must dispose of it by passing it to [`NSReleaseAlertPanel(_:)`](/documentation/AppKit/NSReleaseAlertPanel(_:)).

---

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)