SwiftUI — Data transfer between Structs

passing value between view

Variable Declaration:

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")
}
}
}

Happy Coding🐶!

--

--

--

Passionate iOS developer chasing my dreams toward success

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

iOS 14 Beta 7 — Are we closer to the final public release?

Create a UITableView Programatically | Xcode 12, Swift 5.3

An iPhone displaying a list of songs.

Xamarin Tips: Xamarin.iOS Binding with SecKey API

Material Design Button in SwiftUI

Create a SwiftUI Streaming App with Fun Virtual Backgrounds

SwiftUI 2 | Play Video With AVPlayer

UIKeyCommand — Part 3: macOS Catalyst Menu Items

Memory management in Swift(Heap, Stack, ARC)

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
lyvennitha sasikumar

lyvennitha sasikumar

Passionate iOS developer chasing my dreams toward success

More from Medium

How to test push notifications on iOS simulator

Custom Programmatic UITableViewCell not responding to user input

Auto-generate API.Swift file in Xcode project.

Create Api with Vapor