Copyright ©1998 by AAA+ Software Forschungs- und Entwicklungs Ges.m.b.H. All Rights Reserved.
5 | Joy's interactive application inspector |
This section explains how you can use Joy's application inspector to interactively explore the Rhapsody 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 Rhapsody 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 Rhapsody 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.
You may scroll around with the slider to see that there are an overwhelming number of subclasses (they are counted 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 some are only internal classes that are not documented in the API at all (e.g. all classes starting with an underline character). You can restrict the display to only those instances that existed 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 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 e.g. already have seen Rhapsody'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 bring up the applications About Panel to see a new instance appear. Click on that instance to see its instance methods.
Figure 5: The NSPanel instance and its methods.
Most of the instance methods of NSPanel are inherited from its superclasses. For example we will try to send NSWindow's center method to the NSPanel instance. Double-click the NSPanel instance and then double-click the center method. Press enter (you may want to move the panel to some other location first to see the effect).
Figure 6: Interactively sending a message to an object
You may also try to change the panel's title. Note that you must convert most strings to NSString objects before passing it as a parameter to a Rhapsody method. Your command line should look similar to the following (the name of your NSPanel instance will be different):
joy> NSPanel@0x215d30 setTitle: [@ "My new title"]
As you see, the info panel's title indeed changes. As an exercise, you may try to close it without clicking its close button.
Inspecting non-Joy applications
In the same manner you can interact with the objects in any Rhapsody application. If it is a Joy application it normally has a Joy menu or you can simply add it in InterfaceBuilder. If it is a non-Joy application you have the source code for, you can link Joy to that project as explained in the previous section . If it is a Rhapsody application you don't have the source code for, you can use Joy's Open with Joy service entry:
1. | If you have never used the Open with Joy service before type make_services into a Terminal window, log out and log in again. |
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 provides a more in-depth explanation of some of Joy's features (including the application inspector) and warns you of possible problems.