Changing Object Classes

Just because an interface object belongs to a certain class doesn’t necessarily mean that it has to remain that way. In the following example, you’ll discover that it’s fairly simple to change classes to add extra capabilities to an application. Changing classes may create new attributes (as it does in this example) or offer new Outlets and Actions. Use the Custom Class pane to look for possible options; you may find a better class to suit your needs.

  1. In Interface Builder, select the Term instance in the NIB window. Make sure the associated Terminal design window is visible.

  2. In the Info window, open the Attributes pane (⌘-1). The titlebar of the Info window says “NSWindow Info,” indicating the Term instance’s type. Notice that the Utility Window feature is grayed out; it is not available to the NSWindow class.

  3. Open the Custom Class pane (⌘-5). This pane lets you choose from classes that are closely related to the selected item. Notice that NSWindow is the selected class (it’s highlighted in gray).

  4. Double-click NSPanel. When you do, the NIB window updates to show the NSPanel class, and the Info window shows the class’s attributes.

Get Modding Mac OS X 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.