A self-contained scripting statement.
SDK
- macOS 10.0+
Framework
- Foundation
Declaration
class NSScriptCommand : NSObject
Overview
An instance of NSScript
represents a scripting statement, such as set word 5 of the front document to word 1 of the second document
, and contains the information needed to perform the operation specified by the statement.
When an Apple event reaches a Cocoa application, Cocoa’s built-in scripting support transforms it into a script command (that is, an instance of NSScript
or one of the subclasses provided by Cocoa scripting or by your application) and executes the command in the context of the application. Executing a command means either invoking the selector associated with the command on the object or objects designated to receive the command, or having the command perform its default implementation method (perform
).
Your application most likely calls methods of NSScript
to extract the command arguments. You do this either in the perform
method of a command subclass you have created, or in an object method designated as the selector to handle a particular command.
As part of Cocoa’s standard scripting implementation, NSScript
and its subclasses can handle the default command set for AppleScript's Standard suite for most applications without any subclassing. The Standard suite includes commands such as copy
, count
, create
, delete
, exists
, and move
, as well as common object classes such as application
, document
, and window
.
For more information on working with script commands, see Script Commands in Cocoa Scripting Guide.