Unwinding Segues in SwiftUI

Mohammad Azam
2 min readDec 31, 2020
Give a shoutout to Marius Niveri on social or copy the text below to attribute.

The default navigation in iOS apps allow the user to push views on top of the stack. Once the view is on top of the stack, it is visible to the user. In order to go back to the previous screen, the view is simply popped off the stack.

In some cases the user needs to go from View C back to View A, without having to visit View B. This can be done by using a feature called Unwind Segues. Unwind segues are common in UIKit and can even be setup using UIKit storyboards.

Unfortunately, the process of setting up unwind segues in SwiftUI is not as straight forward. In this article, I will cover how to setup unwind segues in a SwiftUI application.

If you are interested in a video tutorial then you can watch using the YouTube video below:

Implementation

We will start by implementing your ViewA. View A will consist of a NavigationLink, which takes you to View B as shown in the code below:

--

--

Mohammad Azam

Lead instructor at a coding bootcamp. Top iOS mobile instructor on Udemy. Author of multiple books and international speaker. azamsharp.school