Post

Replies

Boosts

Views

Activity

Reply to EnvironmentObject access
I think your question can't be answered without you telling us how you create and pass your GlobalObj in the levels above? Do you use @StateObject for example? Additionally in the WWDC lounges someone asked: I’ve had several intermittent crashes from environment objects being nil when I pass them to a sheet or NavigationLink. [...] The answer was: NavigationLink by design doesn’t flow EnvironmentObjects through to its destination as it’s unclear where the environmentObject should be inherited from. I suspect this might what’s causing your issue. In order to get the behavior you expect, you’ll have to explicitly pass the environmentObject through at that point.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’21