Creates an alert compatible with alerts created using the
NSRun function for display as a warning-style alert.
- macOS 10.3–10.10Deprecated
Title of the alert. When
nilor an empty string, a default localized title is used (“Alert” in English).
Title for the default button. When
nilor an empty string, a default localized button title (“OK” in English) is used.
Title for the alternate button. When
nil, the alternate button is not created.
Title for the other button. When
nil, the other button is not created.
Informative text. This is optional but must be an empty string (
nil. Can embed variable values using a format string; list any necessary arguments for this formatted string at the end of the method’s argument list. For more information on format strings, see Formatting String Objects.
For languages that read left to right, the buttons are laid out on the bottom-right corner of the alert sheet or window, with
default on the right,
alternate on the left, and
other in the middle. The return values identifying these buttons are constants—
NSAlert—that correspond to the keywords.
By default, the first button has a key equivalent of Return, any button with a title of “Cancel” has a key equivalent of Escape, and any button with the title “Don’t Save” has a key equivalent of Command-D (but only if it is not the first button). You can also assign different key equivalents for the buttons using the
key method of the
NSButton class. To access the alert’s buttons, use the
This is a compatibility method. It is designed for easy adoption by apps migrating from the corresponding function-based API. This method uses earlier return values—
NSAlert—compatible with the earlier API, rather than the return values defined by the
NSAlert class, described in Button Return Values.
Unless you must maintain compatibility with existing alert-processing code that uses the function-based API, you should allocate (
alloc) and initialize (
init) the object, and then set its attributes using the appropriate methods of the