---
title: runModal()
framework: appkit
role: symbol
role_heading: Instance Method
path: appkit/nsalert/runmodal()
---

# runModal()

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

## Declaration

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

## Return Value

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

## Discussion

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:. Special Considerations This method can return values other than those specific to the alert buttons (alertFirstButtonReturn, 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:).

## See Also

### Displaying Alerts

- [beginSheetModal(for:completionHandler:)](appkit/nsalert/beginsheetmodal(for:completionhandler:).md)
- [beginSheetModal(for:modalDelegate:didEnd:contextInfo:)](appkit/nsalert/beginsheetmodal(for:modaldelegate:didend:contextinfo:).md)
- [suppressionButton](appkit/nsalert/suppressionbutton.md)
- [showsSuppressionButton](appkit/nsalert/showssuppressionbutton.md)
