Creating PaperController, a Subclass of NSWindowController

In this section, we will create our initial PaperController class with the method that starts up Evaluator:

  1. Double-click the PaperWindow.nib file in PB’s main window to open it up in IB.

  2. Select the Classes tab in the PaperWindow.nib window.

  3. Select the NSWindowController class (under NSObject — use the Search field if necessary).

  4. Choose the Classes Subclass NSWindowController menu command, as shown in Figure 11-9.

Subclassing NSWindowController

Figure 11-9. Subclassing NSWindowController

  1. Type Command-1 to display the myWindowController Class Info panel.

  2. Change the name of your new subclass from “MyWindowController” to “PaperController”.

  3. Add a new outlet named “theText” (note that there is already an outlet called “window”).

  4. Select the File’s Owner under the Instances tab in the PaperWindow.nib window.

  5. Type Command-5 and change the Custom Class of the File’s Owner to PaperController (because the PaperController will load the PaperWindow.nib file).

  6. Control-drag from the File’s Owner icon to the text area inside the window and double-click theText to make a connection, as shown in Figure 11-10.

Connecting File’s Owner to NSTextField inside NSScrollView

Figure 11-10. Connecting File’s Owner to NSTextField inside NSScrollView

  1. Now select the PaperController class under the Classes tab in the PaperWindow.nib window.

  2. Choose ...

Get Building Cocoa Applications: A Step by Step Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.