How to prevent multiple instances of the same window from opening in macOS?
问题 I am making a Mac Menu Bar app and it has a Preferences option. When the user clicks on it, a Preferences window opens up that shows all the settings for the app. I open the Preferences window like: let storyboard = NSStoryboard(name: "Main", bundle: nil) let windowController = storyboard.instantiateController(withIdentifier: "PreferencesWindowController") as! NSWindowController windowController.showWindow(self) File: AppDelegate.swift (above code is run when user clicks on "Preferences") Now