Creating PaperController, a Subclass of NSWindowController
In this section, we will create our initial PaperController class with the method that starts up Evaluator:
Double-click the
PaperWindow.nib
file in PB’s main window to open it up in IB.Select the Classes tab in the
PaperWindow.nib
window.Select the NSWindowController class (under NSObject — use the Search field if necessary).
Choose the Classes → Subclass NSWindowController menu command, as shown in Figure 11-9.
Figure 11-9. Subclassing NSWindowController
Type Command-1 to display the myWindowController Class Info panel.
Change the name of your new subclass from “MyWindowController” to “PaperController”.
Add a new outlet named “theText” (note that there is already an outlet called “window”).
Select the File’s Owner under the Instances tab in the
PaperWindow.nib
window.Type Command-5 and change the Custom Class of the File’s Owner to PaperController (because the PaperController will load the
PaperWindow.nib
file).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.
Figure 11-10. Connecting File’s Owner to NSTextField inside NSScrollView
Now select the PaperController class under the Classes tab in the
PaperWindow.nib
window.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.