(swift, macOS, storyboards)
I open a window with code. Every time the user clicks the button the same window opens again and again. How to avoid that?
This opens well the window, but multiple times:
@IBAction func obrirAmbCodi(_ sender: NSButton) {
let storyboard:NSStoryboard = NSStoryboard(name: "Main", bundle: nil)
guard let controller:NSWindowController = storyboard.instantiateController(withIdentifier: "finestra3") as? NSWindowController else { return }
controller.showWindow(self)
}
If I open the window with a segue (storyboard control drag) I can accomplish that by selecting the window controller > Attributes > Presentation > Single. But it seems that it does not work if I open the window with code