danmihai
(Dan)
1
Hi,
In AppKit, there's the famous NSViewController that can be used to display the whole content of a window. One can easily switch the contents of a window there, by simply swapping the view controller with another one.
How can that be achieved in SwiftUI?
I know one way, but it doesn't seem idiomatic at all, something like:
struct MyView : View {
@State var setupIsDone = false
var body: some View {
if setupIsDone {
FirstView()
} else {
SecondPage()
}
}
}
So this is really tedious, it will turn into a switch statement and you'd have to pass down the the state variable to each subview in order for the subview to change the screen, like a state machine, only badly implemented.
Karl
(👑🦆)
2
This forum is only about the Swift language. Apple has requested that questions/comments about their proprietary frameworks should be asked on the Apple developer forums.
2 Likes
danmihai
(Dan)
3
Thanks Karl,
Should I simply remove the question?
Karl
(👑🦆)
4
You can, or you can leave it. But please ask your question to the appropriate forum.
Thanks