How to know whatt some View actually is from Xcode? Something similar to option-click that shows me the actual type.
//vvvv I need to put the real type here
class HostingController: WKHostingController<ContentView> {
//vvv and the real type here
override var body: ContentView {
// Cannot convert return expression of type 'some View' to return type 'ContentView'
return ContentView().environmentObject(ThemeColor()) // what type does .environmentObject() return?
}
}
So ContentView().environmentObject(ThemeColor()) is some View, I need its type so I can replace ContentView generic type here for it to compile
The problem is HostingController doesn't even compile now after adding the .environmentObject() modifier because it's a generic to type ContentView. I just realize even if I know the real type return from .environmentObject(), it doesn't help me in this situation. I'll just do this:
struct ContentView: View {
var body: some View {
MyApp() // <== MyApp was ContentView
.environmentObject(ThemeColor())
}
}
Phone app SceneDelegate is not generic so you can simply attach .environmentObject(), but watch app HostingController is generic to ContentView so you cannot add any modifier to ContentView().
Edit: if I know the actual type, I can force cast as! So it does help.