Reference main NSWindow in AppDelegate using Storyboard?

前端 未结 1 1997
孤街浪徒
孤街浪徒 2021-01-12 05:32

I am attempting to set an outlet for the main window of my app in my App Delegate, then connect it within Interface Builder. I create the outlet within my App Delegate easil

相关标签:
1条回答
  • 2021-01-12 06:10

    I dont know if this is correct way of doing, but this will solve your problem.

    Decalre a NSWindow property in AppDelegate

    weak var window: NSWindow!
    

    and set the property in something like windowWillLoad of the NSWindowController

    (NSApplication.sharedApplication().delegate as! AppDelegate).window = self.window
    

    You will have to subclass NSWindowController to define windowWillLoad

    0 讨论(0)
提交回复
热议问题