How do I create an IBOutlet for NSWindow Xcode macOS

206 views Asked by At

I am trying to create an IBOutlet for NSWindow in AppDelegate.swift, I am able to create IBOutlets for buttons by control + dragging from storyboard to swift file, but I am not able to do this for NSWindow. How do I do this? Xcode 9.2 Swift 4.0

Thanks

1

There are 1 answers

3
RTXGamer On BEST ANSWER

Create a window property:

weak var window: NSWindow?

Main window reference:

 func applicationDidFinishLaunching(_ aNotification: Notification) {
        window = NSApplication.shared.windows.first
    }