Skip to content

Instantly share code, notes, and snippets.

@below
Last active August 27, 2020 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save below/1426b05fb03a461edbad4d8f7c4a13a9 to your computer and use it in GitHub Desktop.
Save below/1426b05fb03a461edbad4d8f7c4a13a9 to your computer and use it in GitHub Desktop.
Why is this not working?
import SwiftUI
import PlaygroundSupport
struct TestView: View {
@State var foo = "faz"
init() {
foo = "bar"
debugPrint(foo) // prints "faz"
}
var body: some View { Text(foo) }
}
PlaygroundPage.current.setLiveView(TestView())
// Result: faz is displayed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment