Learn how to use SwiftUI Alerts the right way to deliver critical information and gather user decisions. In this video, we’ll go from the basics of showing an alert to best practices for when—and when not—to interrupt your users.
🤔 What you’ll learn:
The purpose of alerts & why they matter
How to show a basic alert with @State
Multiple button options: .default, .cancel, .destructive
Alerts vs. ConfirmationDialog — when to use each
Best practices: concise, accessible, and only for critical events
✅ By the end, you’ll know exactly how to integrate alerts into your SwiftUI apps like a pro.
🖼 Try It Yourself!
Clone or download the full demo project here:
📁 GitHub Repo: https://github.com/NDCSwift/SwiftUIAl...
🔥 Download My Project Files & More! 🔥
👉 Get the source code for this project & other Swift resources here:
🔗 https://ndcswift.github.io/Swift-Proj...
⏱️Timestamps
00:00 - Intro & app example
01:03 - Creating & Presenting an Alert
05:05 - Alert Roles
06:12 - Adding a message
06:52 - Confirmation Dialog
08:44 - Alert vs Confirmation Dialog
09:26 - Customizing Confirmation Dialogs
10:14 - Customizing and using Sheet
11:51 - Wrap up