I want to trigger the update of a subview in SwiftUI by changing the state of a @State variable, since it does not update alone when I change the Wallet Object since it is defined as EnvironmentObject. The thing is that I have to initialize the view with environmentObject, and it returns Some View, and cannot cast it to WalletView as it should seem that it should.
var walletView = WalletView().environmentObject(Wallet(cards: reminders)) if walletView = walletView as? WalletView{ walletView.isPresented = !walletView.isPresented } How can I access the WalletView object?
I've tried:
var walletView = WalletView() let someWalletView = walletView.environmentObject(Wallet(cards: reminders)) walletView.isPresented = !walletView.isPresented but the walletView doesn't seem to update. Any clue?