"Delegation" chapter 6 with Xcode v12.1

Observations about Xcode version 12.1
Chapter 6 “Delegation”

Section: Creating a Code Snippet
Page 101
The button for the snippet library is not in the utility section. Instead, there is now a separate pop-up for all libraries. This change (Xcode V12 versus what book says) was seen in a prior chapter that discussed the “Object Library”, now the same concept is used for “Snippet Library”. There are three ways to access this pop-up.
– At the Main Menu, at the top of the screen, use “View” --> “Show Library”
– Use the keyboard shortcut <‘L’> (that is ‘L’ as in ‘Library’)
– At the top bar of the project window, at the right hand side, click the button marked with a plus-sign ‘+’

With the “Libraries” pop-up showing, select the Snippet Library by clicking on the curly braces button “{ }”.

HOWEVER, this is not how a custom code snippet is created.

As documented in the Xcode 12 help, the new way is to
– In the regular editor, select (highlight) the desired code
– Use the Editor drop down menu: “Main-Menu” --> “Editor” --> “Create Code Snippet”

Section: Creating the User Interface

Page 104:
Does it make sense to dereference the object “textField”? (Also, of course, should use “print” not “println”).

println("string from \(textField) is empty")

Page 104

“Jump Bar” is at top of Editor window, above the editing but below the tabbed, horizontal list of recently used files. The “jump bar” shows a hierarchy consisting of various things. It starts with Project, then the Project-Folder --> etc., --> File-Being-Edited --> Class-Being-Edited. Click on any level of the hierarchy to see more items at that level. Click on the Class to see contained components.

So, at page 104 of the tutorial, with “MainWindowController.swift” being edited, the following appears in the Jump-Bar:

Speakline --> SpeakLine --> MainWindowController.swift --> MainWindowController

Click on the “MainWindowController” at Class level, and components are shown in a drop-down menu. One of the components is “Action methods”; this comes from the “MARK:” comment.

Page 106:
Code in book:
Should be

Page 108:
Code in book:
speakButton.enabled = false
. . . etc . . .

Property has been renamed. Now use:

speakButton.isEnabled = false
. . . etc . . .

Page 113:
Regarding use of “delegate” method and NSWindow and NSWindowDelegate, the description in the book is not correct for Xcode V12. Book has this:

windowShouldClose(sender: AnyObject) -> Bool

In Swift with Xcode V12, the signature has changed. The correct signature is given in the Apple documentation for AppKit that comes with Xcode. The correct signature now is:

windowShouldClose( _: NSWindow) -> Bool

Page 118
The challenge question gives an incorrect hint. Again, the problem is that the signature has changed. Book presents the following:

func windowWillResize( sender: NSWindow, toSize frameSize: NSSize) -> NSSize

For Xcode V12, the following signature must be used, as explained in the Apple documentation:

func windowWillResize( _: NSWindow, to: NSSize) -> NSSize

And by the way, the challenge gives a much nicer result if the window remains half as tall (rather than twice as tall) as it is wide. This matters because the code gets used in the next chapter.

End of issues.