PATH
Mac OS X Documentation >
Cocoa >
Making Your Applications Scriptable
The Scripting Classes
About two dozen public classes in the Foundation framework support scripting in the Yellow Box. (They are in Foundation instead of the Application Kit in case you want to make server programs--which have no user interface--scriptable.) To make an application scriptable, you rarely have to interact directly with objects of any of these classes. Even rarer is the occasion when you need to create a subclass of a scripting class. But the scripting classes are available if you need to do anything more advanced, such as recording.
The following tables describe the purpose of each class, why you might want to use it, and why you might need to subclass it.
Scripting Commands and Scripting Metadata
The following classes represent scripting commands, the context in which commands are executed, and the scripting metadata associated with an application, framework, or bundle. Objects of these classes are automatically created by the scripting system.
Table 4.
Scripting Metadata and Command Classes
Class
|
Description
|
NSScriptSuiteRegistry
|
A shared instance of this class loads and registers the suites associated with an application. Use its methods to get loaded suites, bundles, class descriptions, and command descriptions. Rarely requires subclassing.
|
NSScriptClassDescription
|
Represents a description of a scriptable class in a suite definition. Use its methods to get attributes, relationships, supported commands, and related information. Rarely requires subclassing
|
NSScriptCommandDescription
|
Represents a definition of a command supported by a suite. Use its methods to get command class and return and argument types. Rarely requires subclassing.
|
NSScriptCommand
|
Represents an AppleScript command sent to an application. Use its methods to evaluate object references (receivers and arguments) and execute the command. Apple has implemented subclasses for the major AppleScript commands. You may create a subclass of this class if you define a command with a default implementation or which needs some special argument processing.
|
NSScriptExecutionContext
|
Represents the context in which an AppleScript command is executed and tracks global state related to that command. It should not be subclassed.
|
Object Specifiers and Logical Tests
Objects from this group of classes represent particular AppleScript reference forms. Most of these classes are subclassses of NSObjectSpecifier, an abstract class. Objects of these classes--object specifiers--know how to evaluate themselves within the context of another object specifier that contains them. Some of these classes generate objects that represent relative or logical tests performed with object specifiers (particularly NSWhoseSpecifiers).
Table 5.
Object Specifier Classes
Class
|
Description
|
NSObjectSpecifier
|
An abstract class for concrete subclasses that represent AppleScript reference forms. An object specifier knows how to evaluate itself (to an actual object) in the context of a container specifier.
|
NSPropertySpecifier
|
A subclass of NSObjectSpecifier for object specifiers that represent an attribute or relationship of an object.
|
NSIndexSpecifier
|
A subclass of NSObjectSpecifier for object specifiers that specify an object in a collection by index number.
|
NSRangeSpecifier
|
A subclass of NSObjectSpecifier for object specifiers that specify a range of objects in a collection by index numbers.
|
NSRandomSpecifier
|
A subclass of NSObjectSpecifier for object specifiers that specify an arbitrary object in a collection.
|
NSMiddleSpecifier
|
A subclass of NSObjectSpecifier for object specifiers that specify the middle object in a collection.
|
NSWhoseSpecifier
|
A subclass of NSObjectSpecifier for object specifiers that specify an object in a collection that matches a specified condition defined by a Boolean expression.
|
NSPositionalSpecifier
|
An object of this class represents an insertion point by reference to a point before or after another object, or at the beginning or end of a collection. It contains an object specifier that represents the object referred to for position.
|
NSWhoseTest
|
An abstract class for objects that represent Boolean expressions (qualifiers) involving object specifiers (also called "whose" clauses, as in "word whose color is blue".
|
NSSpecifierTest
|
A subclass of NSWhoseTest for objects that represent a comparison between two objects (which can be object references before being evaluated) using a given comparison method.
|
NSLogicalTest
|
A subclass of NSWhoseTest for objects that represent the Boolean operations AND, OR, and NOT; used with one or more NSSpecifierTests.
|
Key-Value Coding and Value Coercion
Table 6.
Scripting Utility Classes
Class
|
Description
|
NSCoercionHandler
|
A shared instance of this class coerces object values to objects of another class, using information supplied by classes who register with it. Coercions frequently are required during key-value coding.
|
NSKeyValueCodingAdditions
|
Additions to NSObject's implementation of key-value coding that are related to scripting.
|
Making Your Applications ScriptablePrevious | Chapter contents | Next | Book PDF