I have a macOS SwiftUI app with a secondary window that should be opened/displayed if a certain condition occurs. The logic that detects the condition is inside a Swift class.
I see lots of examples where opening a window is done inside another SwiftUI View using something like
struct ContentView: View {
@Environment(\.openWindow) var openWindow
var body: some View {
...
Button("Open window") {
openWindow(id: "secondWindowId")
}
}
In my case, the logic that detects the condition that would prompt the opening of secondWindowId is in a Swift class (not a SwiftUI View).
Is there a standard way to open the window identified with "secondWindowId" from inside a Swift class?
3
0
1.7k