15 Alerts and Closures
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.
NSAlert
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 ...
Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.