Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created October 5, 2020 16:17
Embed
What would you like to do?
variable5.swift
struct ContentView: View {
var body: some View {
SwiftUIViewF()
.onTapGesture {
Greeting.shared.words = "Hello, World!"
}
}
}
final class Greeting: ObservableObject {
@Published var words = "X"
static var shared = Greeting()
}
struct SwiftUIViewF: View {
@ObservedObject var meet = Greeting.shared
var body: some View {
Text(meet.words)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment