Casting UIWindow.rootView to a hosting controller like:
window?.rootViewController as? UIHostingController<MainTabView>
works fine, unless it has environmentObject
s.
As my MainTabView
has been initialized with .environmentObject
, I cannot cast it to UIHostingController<MainTabView>
.
When I try to print rootView
's type, Xcode tells:
<_TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentGS1_V10Panparella11MainTabViewGVS_30_EnvironmentKeyWritingModifierGSqCS2_11GroupsStore___GS4_GSqCS2_18GroupsPresentation____: 0x7fd8afe5da40>
which I suppose is:
UIHostingController<ModifiedContent<MainTabView, _EnvironmentKeyWritingModifier<GroupsStore, GroupsPresentation>>>
but I'm not able to reach _EnvironmentKeyWritingModifier
.
Anybody has an idea?