SwiftUI — Data transfer between Structs

passing value between view
struct ContentView : View {
@State public var InitStr: String = "Hello World from View!" //variable //declaration

var body: some View{
Text("Hello World")
}
}
struct WeatherView: View{@Binding var Str: String = "Hello Text" var body: some View{
Text(Str)
}
}
struct ContentView : View {
@State public var InitStr: String = "Hello World from View!" //variable //declaration

var body: some View{
NavigationLink(destination: WeatherView($InitStr)){//passing initstr //to Str of weatherView
Text("Hello World")
}
}
}

--

--

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