Type Safely

Type Safely

Use a Switch To Display a Different Alert Based On Error Type

Daily Coding Tip 219

Type Safely's avatar
Type Safely
Nov 19, 2022
∙ Paid
yellow and black road sign
Photo by Breana Panaguiton on Unsplash

The .alert modifier takes a closure which returns an Alert, which means a switch can be used to return different values in different situations. Unlike a view, an Alert isn’t a generic type that conforms to a protocol. An Alert is actually just a struct that doesn’t conform to anything.

This means that there is no i…

User's avatar

Continue reading this post for free, courtesy of Type Safely.

Or purchase a paid subscription.
© 2026 Type Safely · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture