@State is not working on iPad Swift Playgrounds

231 Views Asked by At

I'm trying to use SwiftUI on my iPad with Swift Playgrounds. The view below renders fine initially, but unfortunately the view does not update when @State changes, like it does on my Mac. In the little sidebar I can see the closure does get executed though...

I'm using the newest non-beta version of everything.

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())

Thanks.

1

There are 1 best solutions below

0
On

See https://developer.apple.com/forums/thread/677361. Enable Results should be turned off.