Type Safely

Type Safely

Share this post

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

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

Share this post

Type Safely
Type Safely
Use a Switch To Display a Different Alert Based On Error Type
Share
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…

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share