Creates an alert panel.
- macOS 10.0–10.10Deprecated
Creates and runs an alert panel (or dialog) with the title of
title and buttons with titles of
other. The optional alert message specified by
msg should be a static value that can consist of variable values using a format string (list any necessary arguments for this formatted string at the end of the function’s argument list), an unformatted string, or an empty string (
@""), but not
nil. Note that passing an untrusted string in
msg can lead to security issues. See the description of
NSBegin for information on layout of buttons, default parameters, and possible return values.
NSRun runs the panel in a modal event loop.
A Command-D key equivalent for the “Don’t Save” button is provided, if one is found. The button titles are searched for the localized value for “Don’t Save.” If a match is found, that button is assigned a Command-D key equivalent, provided it is not the default button.
If you create a modal panel using
begin, you can assign the key equivalent yourself, using
This function not only creates the panel; it also puts the panel onscreen and runs it using the
run method defined in the
NSApplication class. This method sets up a modal event loop that causes the panel to remain onscreen until the user clicks one of its buttons. This function then removes the panel from the screen list and returns a value that indicates which of the three buttons the user clicked. For efficiency, this function creates the panel the first time it’s called and reuses it on subsequent calls, reconfiguring it if necessary.