Properties2
| Type | Concept |
| Note created | Feb 17, 2025 |
In SwiftUI views, is fairly common to use stateful properties to store and display data. However, that bifold functionality requires a special syntax, marking the variable with a dollar sign ($):
struct ContentView: View {
@State private var name = ""
var body: some View {
Form {
TextField("Enter your name", text: $name) // two way
Text("Hello, \(name)!") // one way, we are only reading
}
}
}