I’m confused at the second line. I understand the first line that you create the window controller first before the window, but when calling the showWindow method, why are we passing in self? I’m understanding “self” refers to the AppDelegate or am I mistaken on that part?

    func applicationDidFinishLaunching(aNotification: NSNotification) {
        let mainWindowController = MainWindowController()
        // Put the window of the window controller on screen
        // Set the property to point to the window controller
        self.mainWindowController = mainWindowController

Yes, and you are not mistaken.

Furthermore, according to the NSWindowController Class Reference, the showWindow function takes a single argument, which can be nil, to identify the control calling it.

Passing in ‘self’ in this case is unnecessary, but we think passing an object for the sender is a good habit to get into. The sender parameter is discussed further in the Controls chapter on page 81.

In attempting to run the code supplied in the Kindle edition for “Showing the Window,” I receive an error on the following line of code

“Cannot invoke ‘showWindow’ with an argument list of type ‘(AppDelegate’)”

For me this is line 22 of the file. See my two screen shots via the links below, the first to the Kindle page, the second to my Xcode session.

Nothing is listed on your errata page for this chapter, let alone this code snippet. Perhaps I have made an error, but I’ve checked my code and I believe it has been entered as indicated in the text. Perhaps your text is in error. Perhaps Swift has changed since you write the text. Perhaps Xcode has a problem. In any case, I’m not able to get any further, so any help would be appreciated. I’m Running Xcode 6.4 on OS X 10.10.4.

Kindle text:

Xcode error:

The Kindle code is correct, and you could have tried commenting out your code( /* … */), then copying and pasting the Kindle code into your file to confirm that the Kindle code runs error free.

To discover your error, copy each line of the Kindle code(or the op’s code) and paste it under the corresponding line in your code. Then compare each pair of lines character by character. You’ll see the problem.

I had the same problem. XCode’s autocomplete put in the class name MainWindowController, not the variable mainWindowController.