Unlock This Episode
Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.
So by using this new API we are solving a huge bug that plagued navigation links in iOS 15 and earlier. So this is a huge win, but we must caveat that there are still a few bugs and quirks even with the fix we have applied. They are not nearly as pernicious as what we saw with navigation links, and there are work arounds to the bugs, but still we want to make it clear that this is not a universal solution.
So, this is all looking fantastic, and in our opinion, this one of the best ways of dealing with navigation in SwiftUI. You get to model your navigation state as a tree of nested enums, so it is very concise and exact. You can deep link any number of levels, and URL deep linking is also quite easy. We haven’t fixed the router that we built previously, but it’s possible and we leave that as an exercise for the viewer.
So, things are looking pretty good, and we could maybe stop right now to rest on our laurels, but there’s actually still one more tool to discuss, and in fact it’s the one that I think everyone was really excited about when announced at WWDC. And that’s the binding initializer for
NavigationStack, which allows you to drive navigation from an array of data.
This form of navigation is incredibly powerful and allows you to even more fully decouple screens, as well as support navigation flows that are difficult, if not impossible, to do with tree-based state modeled on nested enums. However, with this power comes tradeoffs and new complexities, and so you must still consider whether you truly need all of that power.
Let’s take a look at this last new tool of SwiftUI navigation in iOS 16.