sword in the stone   Hayne of Tintagel
Mac OS X  /  Programming  /  ViewHierarchy


The "View Hierarchy" window is a runtime inspector that allows you to examine the hierarchy of NSView objects in the windows of your application. I.e. it is intended as a debugging tool, or just as an aid to understanding.

To use it in your own project, you need only add the following files to your project:

and then add the following line in an appropriate place (e.g. applicationDidFinishLaunching):
[NSBundle loadNibNamed: @"HTViewHierarchy" owner: self];

The "View Hierarchy" window will then show up automatically. You will be able to choose any of the windows in your application from the popup menu and see the hierarchy of views of that window. Clicking on one of the items in the "View Hierarchy" window will flash the corresponding NSView object so you can identify which one it is.

This project provides a demo of the use of the "View Hierarchy" inspector. The MainMenu.nib file has an "Extra Window" provided solely for experimenting with the view inspector. The "MyController" class loads the HTViewHierarchy.nib file in its 'applicationDidFinishLaunching' method as described above. The MainMenu.nib and MyController files would not be used when you incorporate the view inspector in your own project.

download the ViewHierarchy project files (licensed under the GPL)
(Requires the Apple Developer Tools - I used XCode version 2.3)

This project illustrates several aspects of programming for Mac OS X using the Cocoa API: