NSWindowController in Swift. Subclasses and Nib Initialization

In a Swift test project, I subclass NSWindowController. My subclass is NSWindowControllerdesigned to work with a specific Nib file. Therefore, it is advisable that when initializing my window controller, the nib file is automatically loaded by the instance of the window controller. In Objective-C, this was accomplished by doing:

@implementation MyWindowController

- (id)init {
    self = [super initWithWindowNibName:"MyWindowNib"]
    if (self) {
        // whatever
    }
    return self
}

@end

Now, in Swift this is impossible: init()it cannot call super.init(windowNibName:), because later it is declared not as a designated initializer, but as convenient for NSWindowController.

How can this be done in Swift? I do not see how to do this.

P.S.: , , , Window Controller, init(windowNibName:). , , . init(), , "" Nib .

+4
2

init() super.init(windowNibName:), windowNibName.

override var windowNibName: String  {
    get {
        return "MyWindowNib"
    }
}

.

+5

:

override convenience init() {
    self.init(windowNibName: "MyWindowNib")
}

, super, . Confer fooobar.com/questions/188468/...

0

All Articles