Instance Method


Runs the alert as an app-modal dialog and returns the constant positionally identifying the button clicked.


func runModal() -> NSApplication.ModalResponse

Return Value

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


You can create the alert either through the standard allocate–initialize procedure or, if necessary in your app, by using the deprecated compatibility method alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat:.

Special Considerations

If you use alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat: to create an alert, the following constants are used to identify the button used to dismiss the alert: NSAlertDefaultReturn, NSAlertAlternateReturn, and NSAlertOtherReturn. Otherwise, the constants used are the ones described in Button Return Values.

See Also

Displaying Alerts

func beginSheetModal(for: NSWindow, modalDelegate: Any?, didEnd: Selector?, contextInfo: UnsafeMutableRawPointer?)

Runs the alert modally as an alert sheet attached to a specified window.

var suppressionButton: NSButton?

The alert’s suppression checkbox.

var showsSuppressionButton: Bool

Specifies whether the alert includes a suppression checkbox, which you can employ to allow a user to opt out of seeing the alert again.