100 Days of SwiftUI

Day 43

2026-06-01

Project 9, part 1

Learning about (app) navigation.

Though having a course on celestial navigation might be fun 🤔

It’s not all NavigationStack!

Handling navigation the smart way with navigationDestination()

samoyed

We are “separat[ing] the destination from the value”. I’m not quite sure what that means.

  1. attach a value to the NavigationLink. It can be anything, but it must be Hashable
  2. attach a navigationDestination() modifier inside the navigation stack to let it know what to do
  • you can have multiple navigationDestination() calls depending on the type of data you are giving it
  • “most” of Swift’s data types conform to Hashable
  • Hashing is a way to compare to complex objects easily. The hash value for each piece of data should be unique and consistent. In other words, you use hashing to make sure the large file you downloaded is what you thought you downloaded.
  • if you make a struct with properties that are all Hashable you can add the protocol to the struct to make it conform

This is going to be a very confusing thing for me I think. Not that you need Hashable or that you wait until you need the view before you see it, but the process of navigating to a view. Can you style it? How? Nest a new View body?