Created
April 3, 2021 16:35
-
-
Save lammertw/f051201fc39f92ff3c398c41621873fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ObservableCounter: ObservableObject { | |
@Published var count = 0 | |
func increment() { | |
count += 1 | |
} | |
} | |
@main | |
struct MyApp: App { | |
@ObservedObject var counter = ObservableCounter() | |
var body: some Scene { | |
WindowGroup { | |
ContentView() | |
.environmentObject(counter) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment