image

Glossary: Object Model

image

A scriptable application’s world of objects constitutes its object model. Here’s how it works.

A scriptable application’s dictionary defines classes, roughly comparable to the types of “thing” that constitute its world. For example, iTunes defines a playlist class and a track class; the Finder defines a folder class and a file class. Classes can have properties and elements, whose value type can be a class. Thus, in theory, for a given application, there is a hierarchical containment relationship amongst its classes. For example, in iTunes, a playlist “has” tracks, and in the Finder, a folder “has” files.

In theory, this relationship can be expressed as a “tree”, a hierarchical structure starting with the application itself, and containing every object in the application. Indeed, this tree is vital to your use of AppleScript to communicate with a scriptable application, because it is why you are able to refer to an object in the first place. For example, you can speak to the Finder of file 1 of folder "MyFolder" because the Finder “has” folders and a folder “has” files.

This tree of the objects that you can refer to is the application’s object model.

Script Debugger exposes an application’s object model in three forms:

I say “in theory” because in reality things are not so simple. The containment hierarchy is describing what’s possible, not what’s real, and therefore infinite recursions and circularities can result when you try to express it as a simple tree. For example, in the Finder, in real life there could never be an infinite depth of folder containment. In the containment hierarchy diagram, however, you can keep opening “folder” entries to get “folder” entries inside them, and so on, forever and ever (or until you get bored), just because as a theoretical matter, it’s always true that a folder can contain a folder. If this confuses you, and you’d rather see the object model as it exists in reality, use the application explorer.



image
Glossary: Fork Glossary: Scripting Addition
image