NSScriptClassDescription Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in OS X v10.0 and later. |
| Declared in | NSScriptClassDescription.h |
| Companion guides |
Overview
An instance of NSScriptClassDescription describes a script class 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. That includes information about the classes those scriptable objects are created from.
An application’s scriptability information is collected automatically by an instance of NSScriptSuiteRegistry. The registry object creates an NSScriptClassDescription for each class it finds and caches these objects in memory. Cocoa scripting uses registry information in handling scripting requests that target the application.
A class description instance stores the name, attributes, relationships, and supported commands for a class. For example, a scriptable document class for a drawing application might support attributes such as file and file type, relationships such as collections of circles, rectangles, and lines, and commands such as align and rotate.
As with many of the classes in Cocoa’s built-in scripting support, your application may never need to directly work with instances of NSScriptClassDescription. However, one case where you might need access to a class description is if you override objectSpecifier in a scriptable class. For information on how to do this, see Object Specifiers in Cocoa Scripting Guide.
Another case where your application may need access to class description information is if you override indicesOfObjectsByEvaluatingWithContainer:count: in a specifier class.
Although you can subclass NSScriptClassDescription, it is unlikely that you would need to do so, or even to create instances of it.
Tasks
Initializing a Script Class Description
Getting a Script Class Description
Getting Basic Information About the Script Class
-
– className -
– defaultSubcontainerAttributeKey -
– implementationClassName -
– isLocationRequiredToCreateForKey: -
– suiteName
Getting and Comparing Apple Event Codes
Getting Attribute and Relationship Information
-
– hasOrderedToManyRelationshipForKey: -
– hasPropertyForKey: -
– hasReadablePropertyForKey: -
– hasWritablePropertyForKey: -
– keyWithAppleEventCode: -
– typeForKey: -
– isReadOnlyKey:Deprecated in OS X v10.5
Getting Command Information
Class Methods
classDescriptionForClass:
Returns the class description for the specified class or, if it is not scriptable, for the first superclass that is.
Parameters
- aClass
The class whose description is needed.
Return Value
The class description for the class specified by aClass or, if that class isn’t scriptable, for the class description for the first superclass that is. Returns nil if it doesn’t find a scriptable class.
Availability
- Available in OS X v10.5 and later.
Declared In
NSScriptClassDescription.hInstance Methods
appleEventCode
Returns the Apple event code associated with the receiver’s class.
Return Value
The Apple event code associated with the receiver’s class. This is the primary code used to identify the class in Apple events.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptClassDescription.happleEventCodeForKey:
Returns the Apple event code for the specified attribute or relationship in the receiver.
Parameters
- key
The identifying key for an attribute or relationship of the receiver.
Return Value
The four-character Apple event code associated with the attribute or relationship identified by key in the receiver or, if none exists, in the class description for the receiver’s superclass. Returns 0 if no such attribute or relationship is found.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptClassDescription.hclassDescriptionForKey:
Returns the class description instance for the class type of the specified attribute or relationship.
Parameters
- key
The identifying key for an attribute or relationship of the receiver.
Return Value
The instance of NSScriptClassDescription for the type of the attribute or relationship specified by key. Returns nil if no scriptable property corresponds to key.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptClassDescription.hclassName
Returns the name of the class the receiver describes, as provided at initialization time.
Return Value
A class name. This may be either the human-readable name for the class—that is, the name that is used in a script—or the name of the Objective-C class that is instantiated to implement the class. To reliably obtain the implementation name, use implementationClassName.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptClassDescription.hdefaultSubcontainerAttributeKey
Returns the value of the DefaultSubcontainerAttribute entry of the class dictionary from which the receiver was instantiated.
Return Value
The value of the default subcontainer attribute entry. Returns nil if the there was no such entry.
Availability
- Available in OS X v10.2 and later.
Declared In
NSScriptClassDescription.hhasOrderedToManyRelationshipForKey:
Returns a Boolean value indicating whether the described class has an ordered to-many relationship identified by the specified key.
Parameters
- key
The identifying key for a property of the receiver.
Return Value
YES if the described class has an ordered to-many relationship identified by the specified key; otherwise, NO.
Availability
- Available in OS X v10.5 and later.
Declared In
NSScriptClassDescription.hhasPropertyForKey:
Returns a Boolean value indicating whether the described class has a property identified by the specified key.
Parameters
- key
The identifying key for a property of the receiver.
Return Value
YES if the described class has a property identified by the specified key; otherwise, NO.
Availability
- Available in OS X v10.5 and later.
Declared In
NSScriptClassDescription.hhasReadablePropertyForKey:
Returns a Boolean value indicating whether the described class has a readable property identified by the specified key.
Parameters
- key
The identifying key for a property of the receiver.
Return Value
YES if the described class has a readable property identified by the specified key; otherwise, NO.
Discussion
To determine if a property is read-only, invoke hasWritablePropertyForKey:/
Availability
- Available in OS X v10.5 and later.
Declared In
NSScriptClassDescription.hhasWritablePropertyForKey:
Returns a Boolean value indicating whether the described class has a writable property identified by the specified key.
Parameters
- key
The identifying key for a property of the receiver.
Return Value
YES if the described class has a writable property identified by the specified key; otherwise, NO.
Availability
- Available in OS X v10.5 and later.
Declared In
NSScriptClassDescription.himplementationClassName
Returns the name of the Objective-C class instantiated to implement the scripting class.
Return Value
An Objective-C class name.
Discussion
The name returned by the className method for an instance of NSScriptClassDescription resulting from an sdef class declaration is the human-readable name for the class—that is, the name that is used in a script. To obtain the name of the Objective-C class instantiated to implement the class, use implementationClassName.
Availability
- Available in OS X v10.5 and later.
Declared In
NSScriptClassDescription.hinitWithSuiteName:className:dictionary:
Initializes and returns a newly allocated instance of NSScriptClassDescription.
Parameters
- suiteName
The name of the suite (in the application’s scriptability information) that the class belongs to. For example,
"AppName Suite".- className
The name of the class that this instance describes.
- classDeclaration
A class declaration dictionary of the sort that is valid in script suite property list files. This dictionary provides information about the class such as its attributes and relationships.
Return Value
The initialized instance. Returns nil if the event code value for the class description itself is missing or is not an NSString. Also returns nil if the superclass name or any of the subdictionaries of descriptions are not of the right type.
Discussion
This method registers self with the application’s global instance of NSScriptSuiteRegistry.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptClassDescription.hisLocationRequiredToCreateForKey:
Returns a Boolean value indicating whether an insertion location must be specified when creating a new object in the specified to-many relationship of the receiver.
Parameters
- toManyRelationshipKey
The key for the to-many relationship that may require an insertion location.
Return Value
YES if an insertion location must be specified; otherwise, NO.
Discussion
A script command object that creates a new object in a to-many relationship needs to know whether an explicitly specified insertion location is required. It can get this information from an instance of NSScriptClassDescription. For example, NSMakeCommand uses this method to determine whether or not a specific make AppleScript command must have an at parameter.
Availability
- Available in OS X v10.2 and later.
Declared In
NSScriptClassDescription.hkeyWithAppleEventCode:
Given an Apple event code that identifies a property or element class, returns the key for the corresponding attribute, one-to-one relationship, or one-to-many relationship.
Parameters
- appleEventCode
An Apple event code that identifies a property or element class.
Return Value
The key that corresponds to the property or element class identified by appleEventCode in the receiver or, if none exists, in a class description in the receiver’s superclasses.
The four-character Apple event code associated with the attribute or relationship identified by key Returns 0 if no such attribute or relationship is found. Returns nil if it cannot find any such attribute or relationship.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptClassDescription.hmatchesAppleEventCode:
Returns a Boolean value indicating whether a primary or secondary Apple event code in the receiver matches the passed code.
Parameters
- appleEventCode
An Apple event code to compare against the receiver’s primary or secondary codes.
Return Value
YES if the receiver’s primary four-character Apple event code or any of its secondary codes (its synonyms) matches code; otherwise, NO.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptClassDescription.hselectorForCommand:
Returns the selector associated with the receiver for the specified command description.
Parameters
- commandDescription
A description for a script command, such as
duplicate,make, ormove. Encapsulates the scriptability information for that command, such as its Objective-C selector, its argument names and types, and its return type (if any).
Return Value
The selector from the receiver for the command specified by commandDescription. Searches in the receiver first, then in any superclass. Returns NULL if no matching selector is found.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptClassDescription.hsuiteName
Returns the name of the receiver’s suite.
Return Value
The receiver’s suite name. Within an application’s scriptability information, named suites contain related sets of information.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptClassDescription.hsuperclassDescription
Returns the class description instance for the superclass of the receiver’s class.
Return Value
A class description instance that describes the superclass of the receiver’s class. Returns nil if the class has no superclass.
Discussion
The instance of NSScriptClassDescription that describes the superclass can be in the same suite as the receiver or in a different suite.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptClassDescription.hsupportsCommand:
Returns a Boolean value indicating whether the receiver or any superclass supports the specified command.
Parameters
- commandDescription
A description for a script command, such as
duplicate,make, ormove. Encapsulates the scriptability information for that command, such as its Objective-C selector, its argument names and types, and its return type (if any).
Return Value
YES if an the receiver or the instance of NSScriptClassDescription of any superclass of the receiver’s class lists the command described by commandDesc among its supported commands; otherwise, NO.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptClassDescription.htypeForKey:
Returns the name of the declared type of the attribute or relationship identified by the passed key.
Parameters
- key
The identifying key for an attribute, one-to-one relationship, or one-to-many relationship of the receiver.
Return Value
The name of the declared type of the attribute or relationship identified by key; for example, “NSString”. Searches in the receiver first, then in any superclass. Returns nil if no match is found.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptClassDescription.h© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-07-17)