The inspector window in Interface Builder provides the user with access to the attributes of the currently selected objects. The inspector window is divided into several different panes, which are selected using controls at the top of the window (Figure 5-1). The attributes pane is the only pane plug-in developers can customize.
The attributes pane displays the design-time attributes of the currently selected objects. The attributes themselves are divided up and displayed in “sections”, which are collapsible regions consisting of a title bar and content area. The content area of each section contains the attributes associated with a given class in the selected object’s lineage. For example, an instance of the NSButton class contains sections displaying the NSView attributes, NSControl attributes, and NSButton attributes.
The advantage of sections is that they promote greater editability when multiple objects are selected. When multiple objects are selected, Interface Builder displays all of the inspectors that are common among the selected objects. Thus, if an NSButton and NSTextField object are selected, the user sees the Control, View, and Object inspectors. This lets the user modify any of the attributes that are common to the objects in the selection.
Each section in the attributes pane is managed by an inspector object. An inspector object ensures that the controls in the section’s content view remain synchronized with the attributes of the currently selected objects. When one of your custom objects is selected, Interface Builder queries it for the names of the inspector classes needed to display its attributes. Interface Builder provides inspector classes for all of the standard Cocoa classes so you need to provide inspectors only for those classes you use to implement your custom objects. In addition, an inspector class is needed only if your custom view or object classes have attributes that are configurable at design time. If they do not, you do not need to create an inspector class.
The steps for creating an inspector object are as follows:
Define a custom subclass of IBInspector.
Create a nib file with the user interface of your inspector section.
Configure the bindings or write the code needed to synchronize your inspector interface with the currently selected objects.
Register your inspector class with Interface Builder.
Creating Your Inspector Class
Creating Your Inspector’s User Interface
Synchronizing Your Inspector’s Interface
Registering Your Inspector Objects
Last updated: 2007-07-18