Runs the alert modally as an alert sheet attached to a specified window.
- macOS 10.3–10.10Deprecated
The parent window for the sheet.
The delegate for the modal-dialog session.
Message the alert sends to
modalafter the user responds but before the sheet is dismissed.
Contextual data passed to
You can create the required
NSAlert object either through the standard allocate-initialize procedure or by using the compatibility method
alert argument must be a selector that takes three arguments, and the corresponding method should have a declaration modeled on the following example:
alert is the
return specifies which button the user clicked, and
context is the same
context passed in the original message. The
return argument identifies which button was used to dismiss the alert (see this method’s “Special Considerations” section). The modal delegate determines which button was clicked (“OK”, “Cancel”, and so on) and proceeds accordingly.
If you want to dismiss the sheet from within the
alert method before the modal delegate carries out an action in response to the return value, send
NSWindow) to the window object obtained by sending
window to the
alert argument. This allows you to chain sheets, for example, by dismissing one sheet before showing the next from within the
alert method. Note that you should be careful not to call
order on the sheet from elsewhere in your program before the
alert method is invoked because the parent window can hang when another alert is requested. If you need to do this, use the
If you use
alert to create an alert, the following constants are used to identify the button used to dismiss the alert:
NSAlert. Otherwise, the constants used are the ones described in Button Return Values.