Showing Windows In Code

Hi


I have window1 and window2 in the main storyboard and window3 in a different storyboard, and I added button1 and button2

on wibdow1, what code to write in the buttons actions to show window2 and window3 ? I want to know by code nit by option

dragining way.


Kindest Regards

Answered by Claude31 in 394411022

The quick answer is


var myWindowController = NSStoryboard(name: "MyStoryboardFileName", bundle: nil)?.instantiateControllerWithIdentifier("MyWindowControllerIdentifier") as MyWindowControllerClass
myWindowController?.showWindow(self)


Note: not sure the conditional ? after NSStoryboard(name: "MyStoryboardFileName", bundle: nil) is needed.

Get details from here:

https://stackoverflow.com/questions/45119813/how-do-i-open-another-window-in-macos-in-swift-with-cocoa

Accepted Answer

The quick answer is


var myWindowController = NSStoryboard(name: "MyStoryboardFileName", bundle: nil)?.instantiateControllerWithIdentifier("MyWindowControllerIdentifier") as MyWindowControllerClass
myWindowController?.showWindow(self)


Note: not sure the conditional ? after NSStoryboard(name: "MyStoryboardFileName", bundle: nil) is needed.

Get details from here:

https://stackoverflow.com/questions/45119813/how-do-i-open-another-window-in-macos-in-swift-with-cocoa

Showing Windows In Code
 
 
Q