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

# runModal()

Runs the alert as an app-modal dialog and returns the constant that identifies the button clicked.

```
func runModal() -> NSApplication.ModalResponse
```

## Return Value

A response to the alert. See this method’s “Special Considerations” section for details.

## Discussion

You can create the alert either through the standard allocation and initialization procedure or, if necessary in your app, by using the deprecated compatibility method [`alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat:`](/documentation/AppKit/NSAlert/alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat:).

### Special Considerations

This method can return values other than those specific to the alert buttons ([`alertFirstButtonReturn`](/documentation/AppKit/NSApplication/ModalResponse/alertFirstButtonReturn), [`alertSecondButtonReturn`](/documentation/AppKit/NSApplication/ModalResponse/alertSecondButtonReturn), and so on) if the alert is canceled programatically.

If you use `alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat:` to create an alert, the `NSAlertDefaultReturn`, `NSAlertAlternateReturn`, and `NSAlertOtherReturn` constants identify the button used to dismiss the alert. Otherwise, the constants used are the ones described in [`addButton(withTitle:)`](/documentation/AppKit/NSAlert/addButton(withTitle:)).

---

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)