April 2015
Intermediate to advanced
556 pages
17h 47m
English
Occasionally, you will want to warn the user about something by presenting an alert. To do this, you use the NSAlert class. NSAlert saves you the work of designing a custom user interface for a simple and common user interaction, while also providing the user with a consistent experience.
Figure 15.1 shows a basic modal alert:
Figure 15.1 A modal alert
Here is the code used to create and present that alert:
let alert = NSAlert() alert.messageText = "Alert message." alert.informativeText = "A more detailed description of the situation." alert.addButtonWithTitle("Default") alert.addButtonWithTitle("Alternative") ...Read now
Unlock full access