Function

NSGetAlertPanel

Returns an alert panel.

Declaration

id NSGetAlertPanel(NSString *title, NSString *msgFormat, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);

Discussion

Returns an NSPanel that can be used to set up a modal session. A modal session is useful for allowing the user to interrupt the program. During a modal session, you can perform activities while the panel is displayed and check at various points in your program whether the user has clicked one of the panel’s buttons. The arguments for this function are the same as those for NSRunAlertPanel, but unlike that function, no button is displayed if defaultButton is nil.

To set up a modal session, send the Application object beginModalSessionForWindow: with the panel returned by NSGetAlertPanel as its argument. When you want to check if the user has clicked one of the panel’s buttons, use runModalSession:. To end the modal session, use endModalSession:. When you’re finished with the panel created by NSGetAlertPanel, you must dispose of it by passing it to NSReleaseAlertPanel.