Class

NSScriptObjectSpecifier

An abstract class used to represent natural language expressions.

Declaration

@interface NSScriptObjectSpecifier : NSObject

Overview

NSScriptObjectSpecifier is the abstract superclass for classes that instantiate objects called “object specifiers.” An object specifier represents an AppleScript reference form, which is a natural-language expression such as words 10 through 20 or front document or words whose color is red.

The scripting system maps these words or phrases to attributes and relationships of scriptable objects. A reference form rarely occurs in isolation; usually a script statement consists of a series of reference forms preceded by a command and typically connected to each other by of, such as:

get words whose color is blue of paragraph 10 of front document

The expression words whose color is blue of paragraph 10 of front document specifies a location in the application's AppleScript object model—the objects the application makes available to scripters. The classes of objects in the object model often closely match the classes of actual objects in the application, but they are not required to. An object specifier locates objects in the running application that correspond to the specified object model objects.

Your application typically creates object specifiers when it implements the objectSpecifier method for its scriptable classes. That method is defined by the NSScriptObjectSpecifiers protocol.

It is unlikely that you would ever need to create your own subclass of NSScriptObjectSpecifier; the set of valid AppleScript reference forms is determined by Apple Computer and object specifier classes are already implemented for this set. If for some reason 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 probably need to declare any special instance variables and implement an initializer that invokes super’s designated initializer, initWithContainerClassDescription:containerSpecifier:key:, and initializes these variables.

For a comprehensive treatment of object specifiers, including sample code, see Object Specifiers in Cocoa Scripting Guide.

Topics

Obtaining an object specifier for a descriptor

+ objectSpecifierWithDescriptor:

Returns a new object specifier for an Apple event descriptor.

Initializing an object specifier

- initWithContainerClassDescription:containerSpecifier:key:

Returns an NSScriptObjectSpecifier object initialized with the given attributes.

- initWithContainerSpecifier:key:

Returns an NSScriptObjectSpecifier object initialized with a given container specifier and key.

Evaluating an object specifier

- indicesOfObjectsByEvaluatingWithContainer:count:

This primitive method must be overridden by subclasses to return a pointer to an array of indices identifying objects in the key of a given container that are identified by the receiver of the message.

objectsByEvaluatingSpecifier

Returns the actual object represented by the nested series of object specifiers.

- objectsByEvaluatingWithContainers:

Returns the actual object or objects specified by the receiver as evaluated in the context of given container object.

Getting, testing, and setting containers

containerClassDescription

Sets the class description of the receiver’s container specifier to a given specifier.

containerIsObjectBeingTested

Sets whether the receiver’s container should be an object involved in a filter reference or the top-level object.

containerIsRangeContainerObject

Sets whether the receiver’s container is to be the container for a range specifier or a top-level object.

containerSpecifier

Sets the container specifier of the receiver.

Getting and setting child references

childSpecifier

Sets the receiver’s child reference.

Getting and setting object keys

key

Sets the key of the receiver.

keyClassDescription

Returns the class description of the objects specified by the receiver.

Getting evaluation errors

evaluationErrorSpecifier

Returns the object specifier in which an evaluation error occurred.

evaluationErrorNumber

Sets the value of the evaluation error.

Getting a descriptor for the object specifier

descriptor

Returns an Apple event descriptor that represents the receiver.

Constants

NSScriptObjectSpecifier—Specifier Evaluation Errors

NSScriptObjectSpecifier provides the following constants for error codes for specific problems evaluating specifiers:

Initializers

Relationships

Inherits From

Conforms To

See Also

Object Specifiers

NSPropertySpecifier

A specifier for a simple attribute value, a one-to-one relationship, or all elements of a to-many relationship.

NSPositionalSpecifier

A specifier for an insertion point in a container relative to another object in the container.

NSRandomSpecifier

A specifier for an arbitrary object in a collection or, if not a one-to-many relationship, the sole object.

NSRangeSpecifier

A specifier for a range of objects in a container.

NSUniqueIDSpecifier

A specifier for an object in a collection (or container) by unique ID.

NSWhoseSpecifier

A specifier that indicates every object in a collection matching a condition.

NSNameSpecifier

A specifier for an object in a collection (or container) by name.

NSMiddleSpecifier

A specifier indicating the middle object in a collection or, if not a one-to-many relationship, the sole object.

NSIndexSpecifier

A specifier representing an object in a collection (or container) with an index number.

NSRelativeSpecifier

A specifier that indicates an object in a collection by its position relative to another object.