macOS Programming Tutorial: Working with Alerts, Sheets and Modal Windows

Updated on September 25th, 2019

⏱ Reading Time: 2 mins

One of the basic, yet vital things a developer should know when creating macOS apps is how to present alerts, system panels or custom windows to their apps. Regardless of how small or big an app is, it will always be necessary to display an informational message to the user or ask for confirmation. Letting users to search for and open a file from their drive is the case for many kinds of apps, as well as saving back to disk.

Presenting any of the above can happen in two different ways: Either as a modal dialog, or as a sheet. When presenting as a modal dialog, the new window sits on top of the current window and interaction is allowed with that only. There is a title bar and window can be dragged around in the screen.

When presenting a window as a sheet, then there’s no separate window and no dragging can happen. Instead, the new window is sliding in from the top of the current window and looks like it’s a part of it. The common thing with the modal presentation is that the new window stays there until we dismiss it, and it doesn’t allow interaction with any other content underneath.

I would recommend to take a look at the Apple’s Human Interface Guidelines about dialogs, alerts and sheets.

To summarize, today we are going to see:

  • How to present an Open Panel and let users open files of specific types (files with specific extensions).
  • How to present a Save Panel to do the exact opposite and store a file anywhere on the disk.
  • How to show Alerts with different kind of content in them.
  • How to handle a custom window as a sheet.

Let’s get started, and let’s have a quick look of the demo app that we’ll be working on. Then we’ll jump straight into the new stuff we have to learn here today.

→ Keep Reading at AppCoda

Stay Up To Date

Subscribe to my newsletter and get notifiied instantly when I post something new on

    We respect your privacy. Unsubscribe at any time.