Skip to content

Instantly share code, notes, and snippets.

@Thonyvb
Created March 18, 2022 19:39
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 Thonyvb/cfee01d49540f79451270a466dd42716 to your computer and use it in GitHub Desktop.
Save Thonyvb/cfee01d49540f79451270a466dd42716 to your computer and use it in GitHub Desktop.
SwiftUI Environment Object
struct MainView: View {
@StateObject var prices = Prices()
var body: some View {
VStack {
PricesView()
}.environmentObject(prices)
}
}
struct PricesView: View {
@EnvironmentObject var prices: Prices
// …
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment