Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/Foundation.framework |
Availability | Available in Mac OS X v10.0 and later. |
Companion guide | |
Declared in | NSScriptCommandDescription.h |
An instance of NSScriptCommandDescription
describes a script command that a Cocoa application supports.
A scriptable application provides scriptability information that describes the commands and objects scripters can use in scripts that target the application. An application’s scripting information is collected automatically by an instance of NSScriptSuiteRegistry
, which creates an NSScriptCommandDescription
for each command it finds, caches these objects in memory, and installs a command handler for each command.
A script command instance stores the name, class, argument types, and return type of a command. For example, commands in AppleScript’s Core suite include clone
, count
, create
, delete
, exists
, and move
.
The public methods of NSScriptCommandDescription
are used primarily by Cocoa’s built-in scripting support in responding to Apple events that target the application. Although you can subclass the NSScriptCommandDescription
class, it is unlikely that you would need to do so, or to create instances of it.
– appleEventCodeForArgumentWithName:
– argumentNames
– isOptionalArgumentWithName:
– typeForArgumentWithName:
Returns the four-character code for the Apple event class of the receiver’s command.
- (FourCharCode)appleEventClassCode
The Apple event code associated with the receiver’s command. This is the primary code used to identify the command in Apple events.
In an Apple event that specifies a script command, two four character codes—the event class and event ID—together identify the command. You use this method to obtain the event class. You use appleEventCode
to obtain the event ID.
For example, commands in AppleScript’s Core suite, such as clone
, count
, and create
, have an event class code of 'core'
. This code and the event ID code returned by appleEventCode
together specify the necessary information for identifying and dispatching an Apple event.
NSScriptCommandDescription.h
Returns the four-character code for the Apple event ID of the receiver’s command.
- (FourCharCode)appleEventCode
The code for the event ID of the receiver’s command.
This value of the event ID returned by this method, together with the event class code returned by appleEventClassCode
, specifies the necessary information for identifying and dispatching an Apple event.
NSScriptCommandDescription.h
Returns the Apple event code for the specified command argument of the receiver.
- (FourCharCode)appleEventCodeForArgumentWithName:(NSString *)argumentName
The argument name (used as a key) for which to obtain the corresponding Apple event code.
The code for the specified argument.
NSScriptCommandDescription.h
Returns the Apple event code that identifies the command’s return type.
- (FourCharCode)appleEventCodeForReturnType
The event code for the command’s return type.
NSScriptCommandDescription.h
Returns the names (or keys) for all arguments of the receiver’s command.
- (NSArray *)argumentNames
The array of argument names. If there are no arguments for the command, returns an empty array.
NSScriptCommandDescription.h
Returns the name of the class that will be instantiated to handle the command.
- (NSString *)commandClassName
The Objective-C class name (for example, "NSGetCommand"
). This is always NSScriptCommand
or a subclass.
NSScriptCommandDescription.h
Returns the name of the command.
- (NSString *)commandName
The command name as it appears in the application's scriptability information; may be different from what is displayed to the scripter.
NSScriptCommandDescription.h
Creates and returns an instance of the command object described by the receiver.
- (NSScriptCommand *)createCommandInstance
The command object, instantiated from NSScriptCommand
or a subclass.
NSScriptCommandDescription.h
Creates and returns an instance of the command object described by the receiver in the specified memory zone.
- (NSScriptCommand *)createCommandInstanceWithZone:(NSZone *)zone
The memory zone from which to allocate the command.
The command object, instantiated from NSScriptCommand
or a subclass.
NSScriptCommandDescription.h
Initializes and returns a newly allocated instance of NSScriptCommandDescription
.
- (id)initWithSuiteName:(NSString *)suiteName commandName:(NSString *)commandName dictionary:(NSDictionary *)commandDeclaration
The name of the suite (in the application’s scriptability information) that the command belongs to. For example, "AppName Suite"
.
The name of the script command that this instance describes.
A command declaration dictionary of the sort that is valid in script suite property list files. This dictionary provides information about the command such as its argument names and types and return type (if any).
The initialized command description instance. Returns nil
if the event constant or class name for the command description is missing; also returns nil
if the return type or argument values are of the wrong type.
This method registers self
with the application’s global instance of NSScriptSuiteRegistry
and also registers all command arguments with the registry.
NSScriptCommandDescription.h
Returns a Boolean value that indicates whether the command argument identified by the specified argument key is an optional argument.
- (BOOL)isOptionalArgumentWithName:(NSString *)argumentName
Argument name (used as a key) that identifies the command argument to examine.
YES
if the specified argument exists and is optional; otherwise, NO
.
NSScriptCommandDescription.h
Returns the return type of the command.
- (NSString *)returnType
The receiver’s command return type; for example, "NSNumber"
or "NSDictionary"
).
NSScriptCommandDescription.h
Returns the name of the suite that contains the command described by the receiver.
- (NSString *)suiteName
The receiver’s suite name. Within an application’s scriptability information, named suites contain related sets of information.
NSScriptCommandDescription.h
Returns the type of the command argument identified by the specified key.
- (NSString *)typeForArgumentWithName:(NSString *)argumentName
Argument name (used as a key) that identifies the command argument to examine.
The type of the specified command argument. Returns nil
if there is no such argument.
NSScriptCommandDescription.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-04-10)