Nib's custom class won't hook up to class

The nib I am loading is a custom About window for my app. When the 'About' NSMenuItem is pressed I load the nib in AppDelegate in the following manner:

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

var about = NSWindowController()

@IBAction func aboutClicked(sender: NSMenuItem) {
    about = AboutWindow(windowNibName: "AboutWindow") as AboutWindow
    NSBundle.mainBundle().loadNibNamed("AboutWindow", owner: about, topLevelObjects: nil)
}

*both the class that I want to hook up to the nib and nib itself are named 'AboutWindow'.

Once I create my NSWindowController and it's nib file, The custom class option for the nib's NSWindow does not allow me to put in the 'AboutWindow' class that I created alongside the nib.

As you can see the nib's custom class is set to NSWindow and it won't change

Any help on how to hook up this custom class and the nib is greatly appreciated.

Answers


Can you describe what the following doesn't do that you want to be done:

//
//  AboutWindowController.swift
//  AboutWindow
//

import Cocoa

class AboutWindowController: NSWindowController {

    override func windowDidLoad() {
        super.windowDidLoad()

        // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
    }

}

That was hooked up automatically by Xcode to AboutWindowController.xib, whose name I changed to AboutWindow.xib.

Next file:

//
//  AppDelegate.swift
//  AboutWindow
//

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    @IBOutlet weak var window: NSWindow!
    var about = NSWindowController()


    func applicationDidFinishLaunching(aNotification: NSNotification) {
        // Insert code here to initialize your application
    }

    func applicationWillTerminate(aNotification: NSNotification) {
        // Insert code here to tear down your application
    }

    @IBAction func aboutClicked(sender: NSMenuItem) {
        about = AboutWindowController(windowNibName: "AboutWindow")
        about.showWindow(self)

    }


}

In IB, I dragged from the About menu item to the First Responder object to hook up the action. When I run the app and click on the About menu item, the AboutWindow displays.

I did not attempt to change any class names in IB.

Response to comment:

If I change AboutWindowController to this:

//
//  AboutWindowController.swift
//  AboutWindow
//

import Cocoa

class AboutWindowController: NSWindowController {

    override func windowDidLoad() {
        super.windowDidLoad()

        // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.

        println("The About window has loaded")
    }

}

I see the message printed in the console.


Need Your Help

Why do we "PUSH EBP" and "MOV EBP, ESP" in the CALLEE in Assembly?

assembly x86 x86-64 cpu-registers

Why do we push ebp as the first action in the Callee of an Assembly function?

Play2 : Support for Server Name Indication

ssl playframework load-balancing sni

Does Play2.0.x support Server Name Indication?