Copyright ©1998 by AAA+ Software Forschungs- und Entwicklungs Ges.m.b.H.  All Rights Reserved.

6 Joy's interactive application inspector





This section explains how you can use Joy's application inspector to interactively explore the Mac OS X API.



Inspecting a Joy application

First bring up a Joy command window by double-clicking JoyTerminal.app in the folder /Local/Library/Joy/Examples/JoyTerminal. Drag down the divider bar just beyond the window's title bar to unhide the application inspector.


Figure 1: A Joy command window and its built-in application inspector.

This browser allows you to interactively experiment with the Mac OS X class hierarchy.  As you can see, there are several root classes.  Some of them are internal (non-documented) classes, NXProxy and Object are there for historical reasons (they used to be the NEXTSTEP root classes), NSObject and NSProxy are the only documented root classes of the Mac OS X class hierarchy.

Click on the NSObject class to see all its subclasses. The subclasses will show up in the second column of the browser:


Figure 2: NSObject and its many subclasses.

Scrolling shows that there are an overwhelming number of subclasses. The exact number is displayed in the title of the browser column.  But don't be afraid, you do not have to study all of these classes. Some are needed only rarely, and others are internal classes that are not documented in the API (for example all the classes that with an underscore character). You can restrict the display to those classes which had instances when the browser window was loaded (we will show later how you can load the browser window into other applications). Drag the pop-up button on the top of the browser to Instantiated Subclasses:


Figure 3: Instantiated subclasses of NSObject.

You can now experiment with the browser to find some interesting classes. Most of the classes which make up the graphical user interface are subclasses of NSResponder. For example, you will find the NSBrowser class (whose only instance is the browser you are currently working with) or the NSApplication class (whose only instance is the application you are currently running). The NSWindow class is a direct subclass of NSResponder. The only instance of NSWindow is the window which displays the browser, the pop-up and the other graphical user interface elements. NSWindow also has an instantiated subclass, NSPanel:


Figure 4: NSPanel, a subclass of NSWindow.

If you switch the pop-up button back to Subclasses you can see that NSPanel has many subclasses (you may, for example, already have seen Mac OS X's NSColorPanel in other applications).  Switch the pop-up to Instances and select the All switch to the instances of NSPanel and all its subclasses.  Select the Auto-update switch and select the menu item About JoyTerminal... in the menu to see a new instance appear.  Click on that instance to see its instance methods.


Figure 6: Interactively sending a message to an object

You may also try to change the panel's title. Your command line should look similar to the following (the address of your NSPanel instance will be different):

    js> [(NSPanel *)0x215d30 setTitle: "My new title"]

As you see, the info panel's title changes.  As an exercise, try to close it without clicking its close button.

Inspecting non-Joy applications

Above you saw how to interact with objects in the JoyTerminal application.  In the same manner you can interact with objects in any Mac OS X application.  A Joy application normally has a Joy menu; if not one can simply be added in InterfaceBuilder.  Non-Joy applications for which you have source can be linked with Joy as explained in the previous section . If it is a Mac OS X application you don't have the source code for, you can use Joy's Open with Joy feature:
  1. If you have just installed Joy and you have not logged out since then, log out and log in again or type make_services into a Terminal window.
  2. Select an application in the File Viewer.
  3. Choose the Open with Joy item in the Joy submenu of the Services menu. This launches the application and adds a Joy menu with a Command Window... item to its menu bar.
  4. Load the application inspector by selecting this item and dragging down the window's divider bar.

The next section contains some useful tips and tricks for developing projects in Joy.