How can I programmatically select which WindowGroup to open when the my application is launched? For example:
@main
struct SampleWorkingApp: App
{
var body: some Scene {
WindowGroup(id: "wg1") {
ViewOne()
}
WindowGroup(id: "wg2") {
ViewTwo()
}
}
}
I want to select between wg1 and wg2 depending on a value in UserDefaults.standard.
The following code produces a compile error, but it shows what I want to do.
@AppStorage("showFirstView") private var showFirstView = true
var body: some Scene {
if showFirstView {
WindowGroup(id: "wg1") {
ViewOne()
}
} else {
WindowGroup(id: "wg2") {
ViewTwo()
}
}
}