Created
May 7, 2020 03:23
-
-
Save karthironald/e7d343a63044140b2c8bd444dfa1c4b7 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 Order: ObservableObject { | |
@Published var items = [MenuItem]() | |
} | |
class SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
var window: UIWindow? | |
var order = Order() | |
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
... | |
let contentView = AppView().environmentObject(order) // Setting order in environment of AppView() which is TabView in my case. | |
... | |
} | |
} | |
struct CheckoutView: View { // CheckoutView is one of the tab in TabView. Child view of AppView. So CheckoutView can access saved order from parent's environment | |
@EnvironmentObject var order: Order | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment