Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 15. Using Alert Panels

Chapter 15. Using Alert Panels

Occasionally, you will want to warn the user about something by means of an Alert panel. Alert panels are easy to create. While most things in Cocoa are object oriented, showing a modal Alert panel is typically done with a C function: NSRunAlertPanel(). Here is the declaration:

NSInteger NSRunAlertPanel(NSString *title,
                          NSString *msg,
                          NSString *defaultButton,
                          NSString *alternateButton,
                          NSString *otherButton, ...);

The following code would result in the Alert panel shown in Figure 15.1:

NSInteger choice = NSRunAlertPanel(@"Title", @"Message",
                                  @"Default", @"Alternate", @"Other");

Figure 15.1. Example Alert Panel


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial