Post

Replies

Boosts

Views

Activity

Playgrounds App on iPad not updating UI on @State change
iPad Pro running iOS 14.4, Playgrounds App version 3.4 Super simple @State example doesn’t update the UI. Clicking the button increments the tapCount variable, but the UI doesn’t update to show the new value. Isn’t it supposed to? Am I using an old code example or otherwise doing something wrong? This exact same code works fine on a Playground in Xcode. Swift import SwiftUI import PlaygroundSupport struct ContentView: View {     @State private var tapCount = 0     var body: some View {         Button("Tap count: \(tapCount)") {             tapCount += 1         }     } } PlaygroundPage.current.setLiveView(ContentView())
5
0
1.9k
Feb ’21