Inspector

 


 

An Inspector can be used for examining and modifying the inner state of objects. Typically an Inspector is opened by sending an object an #inspect message, or by evaluating an expression with the Workspace/Inspect-It command (Ctrl+I). Some other tools, such as the Debugger also have commands or operations for opening appropriate Inspectors.

There are, in fact, a number of different inspectors each specialized for the task of inspecting different classes of object. They all follow the same basic two-pane layout:

The leftmost, Attribute, pane shows a list of the attributes of the object which can be displayed in the rightmost, Value Workspace, pane. The attributes are typically the instance variables (named or indexed), but may include additional useful aspects (e.g. the source code of a compiled method). Some specialized inspectors hide the internals of the object, and list only their externally accessible attributes; e.g. in the case of a Dictionary inspector, only the key values are shown.

Using the workspace

Since it acts identically to any other Workspace, expressions can be evaluated in the Value Workspace pane. The context for the evaluation will be the inspected object itself (i.e. 'self' in the evaluation is identical to the inspected object).

Modifying attributes

It is possible to modify the value of a selected attribute by using the Workspace/Accept command after entering an expression in the Value Workspace pane. The result of the expression is assigned back to the selected attribute.

Cascading Inspectors

You can open additional Inspectors to "drill down" into an object by using the context menu of the Attribute pane or by double-clicking over the aspect itself. The context menu also includes a useful Inspect references command that opens another Inspector displaying an array containing all objects that directly reference the selected aspect's object.

Tip: this can be helpful when attempting to track down the references to an object that are preventing it from being garbage collected.