Objective-Everything Release 5. Copyright ©1994-1998 by TipTop Software, Inc. All Rights Reserved.
The Objective-Browser's main window contains a browser with a number of columns. Each column corresponds to an OB node (cell). (The terms node and cell are used interchangeably.) A node corresponds to an object or some other piece of information in the system (e.g., a method). In the top part of each column, an image and a name associated with the node are displayed.
Below the node name there is a popup button which is used to select the subnode category. Each OB node, depending on what it represents, has different kinds of subnodes associated with it, i.e., subnode categories. For example, if a node corresponds to an object, categories might include instance variables, methods, etc.
Now, a node has a number of subnodes for each of its subnode categories. For example, the subnodes of a bundle object corresponding to the "classes" category are nodes corresponding to the compiled classes defined in the bundle. The subnodes of an array object corresponding to the "array contents" category are nodes corresponding to the objects in the array, etc.
In this picture, the main node is "NSApplication". The subnode category is "all subinstances". The object "<TTApplication:0x118998>" (which happens to be the NSApp object), is the selected subnode of NSApplication.
A node can have a number of inspectors associated with it for each category. In practice, however, the associated inspector list most often does not depend on the selected category.
The above picture shows Objective-Browser inspector for the NSApp object in ObjShell.app displaying object attributes (instance variables).
One way to run Objective-Browser is by click a menu item in Objective->Browse.
In addition, each of the languages supports the "browse" command:
Python |
import AppKit AppKit.browse([object[,path]]) |
Tcl |
browse ?object ?path?? |
Perl |
use AppKit browse([object[,path]]) |
ObjC |
Class TTObjBrowserClass; [TTInterp loadBrowser]; TTObjBrowserClass=objc_getClass("TTObjBrowser"); [TTObjBrowserClass browseFromObject:object path:path] |
The optional object argument specifies the root object in the browser. If it is nil, then the browser will display general information about the running application such as bundles that comprise it, root classes, etc.
The optional path argument specifies the path to select in the browser. The browser path consists of path elements which are separated by '/'.
category~filter:item
Category is the browser category to select.
Filter is optional.
Item is the item to select in the corresponding column.
For example:
AppKit.browse(CGlob.NSApp, 'attributes:_keyWindow/methods~[mM]enu')
Runs a browser on the NSApp object, and selects the "_keyWindow" element in the "attributes" category in the first column, and the "methods" category filtered by the "[mM]enu" pattern. I.e., the above command will display all methods that the current key window responds to, and which have "menu" in their name.
Note: By default, filter expressions are glob expressions. If you want to use regular expressions, you can change that in the Objective->Info->Preferences panel.
All examples assume that the following is executed in each of the languages:
Python |
from ObjPy import * import AppKit |
Tcl | - |
Perl |
use ObjPerl; use AppKit; |
ObjC |
Class TTObjBrowserClass; [TTInterp loadBrowser]; TTObjBrowserClass=objc_getClass("TTObjBrowser"); |
GUI | Click Objective->Browse->Bundles (Cmd-B) |
Python | AppKit.browse(nil,'bundles') |
Tcl | browse [nil] "bundles" |
Perl | browse nil, 'bundles'; |
ObjC | [TTObjBrowserClass browseFromObject:nil path:@"bundles"] |
Select a bundle in the browser and select "classes" category.
GUI | Click Objective->Browse->Classes. Select a class (e.g., NSObject). Switch popup to "subclasses". Select a subclass, etc. |
Python | AppKit.browse(nil,'root classes') |
Tcl | browse [nil] "root classes" |
Perl | browse nil, 'root classes'; |
ObjC | [TTObjBrowserClass browseFromObject:nil path:@"root classes"] |
To see instance methods of a class, switch popup to "instance
methods".
To see class methods of a class, switch popup to "methods".
To see instance variables of a class, switch popup to "instance
vars".
To see "unparse", header file, or documentation for a
class, bring inspector up (click the "(i)" button in the browser
toolbar), and switch inspector to unparse, header, or documentation.
Unparse lets you see what an object, class, or protocol actually looks like in the runtime system.The unparse command is also available in all languages.
E.g.: to browse your home directory:
GUI | n/a |
Python | AppKit.browse(C.NSHomeDirectory()) |
Tcl | browse [NSHomeDirectory] |
Perl | browse C::NSHomeDirectory(); |
ObjC | [TTObjBrowserClass browseFromObject:NSHomeDirectory() path:nil] |
E.g.: find all *[Dd]isplay* selectors.
GUI | Click Objective->Browse->Bundles, switch to 'selectors', and type [Dd]isplay in the filter field. |
Python | AppKit.browse(nil,'selectors~[Dd]isplay') |
Tcl | |
Perl | |
ObjC |
GUI | Click Objective->Browse->Bundles, switch to 'selectors', and type 'openFile:' in the filter field, select 'openFile:' in the first column, and make sure that 'implementors' category is selected. |
Python | AppKit.browse(nil,'selectors~openFile:openFile:/implementors') |
Tcl | |
Perl | |
ObjC |
E.g.: find all instances of NSWindow class.
GUI | Navigate to NSWindow class, then select "instances" category |
Python | AppKit.browse(C.NSWindow, 'instances') |
Tcl | |
Perl | |
ObjC |
If you want to see all subinstances of the selected class, select "all subinstances" instead of "instances". In this example, the browse will also show you all instances of NSPanel, etc. (any NSWindow subclasses).
Send a message to a certain instance. Bring the interactor window (click the "Interactor" button in the toolbar), select the instance in the browser, drag the icon representing the instance into the interactor, and type the message statement.
E.g.: find all subclasses of NSObject which have live instances.
GUI | Click Objective->Browse->Classes, select NSObject in the first column, and switch popup to category "instantiated subclasses" or "all instantiated subclasses" in the second column |
Python | AppKit.browse(C.NSObject,'all instantiated subclasses') |
Tcl | |
Perl | |
ObjC |
Too see the actual instanaces of a certain class, select the class and switch popup to "instances".
GUI | - |
Python | |
Tcl | browse $interp |
Perl | |
ObjC |
Switch popup to "globals" or "commands". Select an item, and bring Inspector up to see details.
In InterfaceBuilder, make sure that ObjPalette is loaded. Bring an interactor window (Tools->Objective->Interact->Interactor, and select "Tcl"). Override implementation of method -showInfoPanel: for NSApp. This method is invoked when you click "About InterfaceBuilder". Note that [$NSApp class] is IB. You can type "unparse $NSApp" to see what $NSApp responds to. In the interactor window type:
category IB { method - (void)showInfoPanel:(id)sender { NSRunAlertPanel "Tcl Sez" "Hello World!" "Foo" "Bar" "Baz" } }
Now, if you click "About InterfaceBuilder" you get the new implementation
To change method implementation using OB, type:
browse $NSApp
switch popup to methods and select showInfoPanel:, or simply type:
browse $NSApp "methods:showInfoPanel:"
Bring Inspector up. Edit method implementation in the Inspector to read:
NSRunAlertPanel "Tcl Sez" "Hello World!" "Foo" "Bar" "Baz" ex showInfoPanel: $sender
and click OK.
(The "ex" message command is like "super",
except that it goes one category back as opposed to one class up like
super does. If there is no previous category implementation, ex behaves
exactly like super. See language reference for complete description of the
"ex" message command.)
Now, when you click "About InterfaceBuilder", or invoke "$NSApp showInfoPanel: [nil]" directly from the interactor, the new implementation is invoked which shows an alert panel, and then invokes the previous implementation, i.e., the standard InterfaceBuilder info panel.
[Editing method implementations may not be available if the language source code is discarded by the language.]
GUI | Objective->Browse->Bundles, switch popup to "functions", "globals", "constants", or "types". |
Python | AppKit.browse(nil,'functions') |
Tcl | browse [nil] "globals" |
Perl | browse nil, "constants" |
ObjC | [TTObjBrowserClass browseFromObject:nil path:@"types"] |
Bring up Inspector. The inspector will show details of the item that's selected in the browser window.
You can browse Java classes and instances in OB just like you can browse any ObjC classes and instances. Currently, any Java classes and associated methods appear in browser as native ObjC methods. I.e., OB provides ObjC-centric view into the Java world.