Last active
September 3, 2021 13:53
-
-
Save ucargiray/22da3ffd89391c57c8f58b1c5daf60ac to your computer and use it in GitHub Desktop.
First example for @State property wrapper.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@State private var infoString : String? | |
var body: some View { | |
VStack { | |
Text(infoString ?? "No name") | |
Button("Change text") { | |
infoString = "Giray" | |
} | |
} | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment