Exploring Cocoa with F-Script


This makes it easy to navigate the class hierarchy and to access class methods. In fact, you manipulate classes through the browser in the same way as other objects. This is because Cocoa classes are themselves regular objects. Indeed, each class is itself an instance of another class (called a meta-class) automatically created by the object system... and meta-classes are themselves objects. Since F-Script makes it so easy to browse these different levels, it can be useful to have a clear view of the topology of the Cocoa class system. We illustrate it below, using the Cocoa NSBox class as example.

While this almost always works well, automatically introspecting values of declared properties can be unssafe and can result in undefined behavior. Indeed, it requires calling properties accessors to get at the values, which might not always be a valid action (while most API avoid such brittleness, a class can, in principle, require as a precondition that a given property is read only when the object is in a given logical state). To cope with such situations, F-Script lets you suppress automatic property introspection, through an option in the preference panel.

In a Cocoa application, each graphical component corresponds to an object (typicaly, an NSView). The object browser lets you select a graphical component and browse the relevant object. To do so, first click the Select View button. The cursor changes into a little cross and then all that is required is to click on the visual object that you want to browse. To provides you with immediate feedback and to show the surface covered by the views on screen, the color of the view that is under the cursor is temporarily modified as the cursor moves. A HUD near the cursor displays information about the view underneath.

Method invocation follows the F-Script rules.