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.
- macOS 10.10+
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:
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
indicesOfObjectsByEvaluating(withContainer: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,
init(containerClassDescription:containerSpecifier:key:), and initializes these variables.