-
Re: Two windows from the beginning
Claude31 Dec 4, 2019 9:56 AM (in response to narcisfromgirona)Here is my setup, in such a case.
The second window uses a windowController
I have a global (in a singleton in fact) for the secondController:
secondController = SecondController() // In fact, initialized with some parameters
class SecondController: NSWindowController
// In its init, I call
self.init(windowNibName: NSNib.Name(rawValue: "TheNibName"))
Now, to open the window, I just call
secondController.showWindow(self) // nil ou self
Hope that helps. Tell me if you need more details.
-
Re: Two windows from the beginning
narcisfromgirona Dec 5, 2019 4:17 AM (in response to Claude31)Thank you Claude31. Can you specify where do you put each part of the code, please? Remember that I use storyboard. (I am not familiar with the previous way)
-
Re: Two windows from the beginning
Claude31 Dec 5, 2019 4:34 AM (in response to narcisfromgirona)It is even simpler with storyboard.
All you have to do is put this in applicationDidFinishLaunching.
Note: SecondWindowID is the stroryboard ID of the second windowController.
func applicationDidFinishLaunching(_ aNotification: Notification) { // Insert code here to initialize your application let storyboard = NSStoryboard(name: "Main", bundle: nil) if let windowController = storyboard.instantiateController(withIdentifier: "SecondWindowID") as? NSWindowController { windowController.showWindow(self) } }
-
-