AppleScript recognizes many types of references. For the standard reference forms, Cocoa defines subclasses of the abstract class NSScriptObjectSpecifier. These classes are shown in Table 6-1. Each of these object specifier classes deals with identifying objects in collections (NSArray objects).
These classes are unusual in that they provide one of the few examples where your application routinely creates instances of scripting classes defined by Cocoa. You do that in the object specifier methods for your scriptable classes. For more information on these and related classes, see also Table 9-2.
It is unlikely that you will need to subclass any of these classes, as they already cover the standard set of valid AppleScript reference forms. However, if you do need to create a subclass, you must override the primitive method indicesOfObjectsByEvaluatingWithContainer:count: to return indices to the elements within the container whose values are matched with the child specifier's key. In addition, you may need to declare any special instance variables and implement an initializer that invokes the designated initializer of its superclass, initWithContainerClassDescription:containerSpecifier:key:, and initializes these variables.
In addition to the concrete subclasses of NSScriptObjectSpecifier shown in Table 6-1, Cocoa provides other classes that assist the object-specifier classes in evaluation. Instances of these classes help to indicate relative position and represent Boolean and logical expressions in which object specifiers are involved.
A script statement can also contain filter references, which identify objects in containers based on the conditions specified in Boolean expressions. These expressions can be linked together by logical operators (AND, OR, NOT) and return the appropriate true or false value. Filter references begin with the words whose or where, as in get words where color is blue or color is red and rectangles whose x position is greater than 45. These references can contain phrases such as is, is equal to or is greater than, as well as their symbolic equivalents (such as = and >).
Instances of the NSWhoseSpecifier class represent filter reference forms in Cocoa. These instances hold a “test” instance variable, which is an NSScriptWhoseTest object.
For information about these and related classes, see “Object Specifiers, Logical Tests, and Related Categories.”
Last updated: 2008-03-11