Popup menus in Cocoa are called alerts. There are two kinds of alerts in macOS: alert panels and alert sheets. This video explains alert sheets—how to create them and make them appear in macOS apps.
- The difference between an Alert Panel…and an Alert Sheet is that an Alert Sheet…gives you a few more options.…For example, you can add multiple buttons to an alert sheet,…and you can respond to when a specific button is clicked.…Here I am in my didClickButton method,…and I'm actually going to use the same class,…which is NSAlert to handle my Alert Sheet.…So the same class works for both…Alert Panels and Alert Sheets.…I'll delete alert.runModal…and then I'm going to add a couple buttons.…
alert.addButton(withTitle)…Pass in the title for a button.…Same thing for a second button,…and the same thing for a third button.…alert.addButton(withTitle) and the button will be Button 3.…Now, to show the alerts, we call alert.beginSheetModal…for window completionHandler.…I'm going to press Return to have Xcode…write that out for me,…and then I need to pass in an NSWindow.…
Well, I already have…that window property declared on line 14,…so I'll pass in my window right there.…And then we need to have our completionHandler.…I'll tab over to that, press the Return key on it,…
- Installing your development tools
- Working with Xcode and the MVC pattern
- Creating basic interactions
- Creating delegate classes
- Building a user interface
- Laying out the UI
- Working with data and table views
- Binding data objects to the UI
- Debugging your app
- Distributing the app
Skill Level Beginner
1. Get Started
2. Core Cocoa Skills
4. Create User Interfaces
5. Arrange User Interfaces
6. Use Data Controls
7. Debug and Troubleshoot
8. Distribute an Application
9. Finishing Touches
Create full screen apps1m 51s
Next steps1m 21s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.