Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get instance of main window controller in app delegate

Tags:

xcode

macos

swift

I know that, for iOS, you can reference the root view controller from the app delegate like so:

var rootViewController = self.window!.rootViewController

How does one reference the main window controller from the app delegate when targeting OS X? I would like to pass a variable (the managed object context) this way, as I have read that it is a good solution for referencing the moc.

like image 792
redeyes Avatar asked Oct 03 '14 23:10

redeyes


1 Answers

You can access the NSWindowController instance of the main NSWindow like this:

NSApplication.sharedApplication().mainWindow?.windowController
like image 135
seb Avatar answered Oct 13 '22 01:10

seb