State

#state

Overview

Structs are normally Constant. You cannot change the value in it. But @State gives them that ability.

struct ContentView: View {
    @State var tapCount = 0

    var body: some View {
        Button("Tap Count: \(tapCount)") {
            tapCount += 1
        }
    }
}

Sample Codes

Sources

Videos

Articles / Documents

See Also

Last updated