Nib 的自定义 class 不会连接到 class

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

我正在加载的笔尖是我的应用程序的自定义 About window。当按下 'About' NSMenuItem 时,我按以下方式在 AppDelegate 中加载笔尖:

@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)
}

*我想连接到 nib 的 class 和 nib 本身都被命名为 'AboutWindow'。

一旦我创建了我的 NSWindowController 和它的 nib 文件,nib 的 NSWindow 的自定义 class 选项不允许我放入我在旁边创建的 'AboutWindow' class笔尖

如您所见,笔尖的自定义设置 class 设置为 NSWindow 且不会更改

非常感谢任何有关如何连接此自定义 class 和笔尖的帮助。

您能描述一下您希望完成以下哪些事情没有做的事情吗:

//
//  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.
    }

}

Xcode 自动连接到 AboutWindowController.xib,我把名字改成 AboutWindow.xib

下一个文件:

//
//  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)

    }


}

在 IB 中,我从“关于”菜单项拖动到“第一响应者”对象以连接操作。当我 运行 应用程序并单击关于菜单项时,会显示关于窗口。

我没有尝试更改 IB 中的任何 class 名称。

回复评论:

如果我将 AboutWindowController 更改为:

//
//  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")
    }

}

我看到控制台中打印的消息。