Passing Data between Views in SwiftUI using a property
By the end of this tutorial, you will be able to pass data using a property from a primary view to a modally presented secondary view in SwiftUI.

When you have multiple views in your SwiftUI App, you often need to share data from one view to the next one. If you've been programming for iOS/iPadOS for a while now, you know that this is something we use to do using a prepareForSegue
. However, if you're a newbie, you won't have any problem following this tutorial. There is no need for any previous knowledge of UIKit to pass data between Views this using SwiftUI.
This tutorial is the first of a series that will explore 4 different solutions for passing data between views:
- Passing Data between Views using a property
- Passing Data between Views using @State and @Binding
- Passing data via the view’s environment
- Passing data via
@ObservedObject
and@StateObject
Become a free member or log in to proceed.