Passing data through views by closures in Swift UI

Photo by fabio on Unsplash
struct FirstView: View {
@State var name = ""

var body: some View {
NavigationView {
VStack {
Text("Enter your name below:")
TextField("name...", text: $name)
NavigationLink(destination: SomeView(name: name)) {
Text("Next page!")
}
}
}
}
}
struct SecondView: View {
var name: String!
var body: some View {
VStack {
Text(name)
}
}
}

--

--

var title = “iOS Engineer @ Lunchbox”

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store