NSScriptSuiteRegistry Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSScriptSuiteRegistry.h |
Overview
NSScriptSuiteRegistry functions as the top-level repository of scriptability information for an application at runtime.
Scriptability information specifies the terminology available for use in scripts that target an application. It also provides information, used by AppleScript and by Cocoa, about how support for that terminology is implemented in the application. This information includes descriptions of the scriptable object classes in an application and of the commands the application supports.
There are two standard formats for supplying scriptability information: the older script suite format, consisting of a script suite file and one or more script terminology files, and the newer scripting definition (or sdef) format, consisting of a single sdef file.
There is one instance of NSScriptSuiteRegistry per scriptable application. This registry object collects scriptability information when the application first needs to respond to an Apple event for which Cocoa hasn't installed a default event handler. It then creates one instance of NSScriptClassDescription for each object class and one instance of NSScriptCommandDescription for each command class, and installs a command handler for each command.
When a user executes an AppleScript script, Apple events are sent to the targeted application. Using the information stored in the registry object, Cocoa automatically converts incoming Apple events into script commands (based on NSScriptCommand or a subclass) that manipulate objects in the application.
The public methods of NSScriptSuiteRegistry are used primarily by Cocoa’s built-in scripting support. You should not need to create a subclass of NSScriptSuiteRegistry.
For information on scriptability information formats, loading of scriptability information, and related topics, see "Scriptability Information" in Overview of Cocoa Support for Scriptable Applications in Cocoa Scripting Guide.
Tasks
Getting and Setting the Shared Instance
Getting Suite Information
Getting and Registering Class Descriptions
Getting and Registering Command Descriptions
-
– commandDescriptionsInSuite: -
– commandDescriptionWithAppleEventClass:andAppleEventCode: -
– registerCommandDescription:
Getting Other Suite Information
Loading Suites
Class Methods
setSharedScriptSuiteRegistry:
Sets the single, shared instance of NSScriptSuiteRegistry to registry.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptSuiteRegistry.hsharedScriptSuiteRegistry
Returns the single, shared instance of NSScriptSuiteRegistry, creating it first if it doesn’t exist.
Discussion
If it creates an instance, and if the application provides scriptability information in the script suite format, the method loads suite definitions in all frameworks and other bundles that the application currently imports or includes; if information is provided in the sdef format, the method loads information only from the specified sdef file. If in reading scriptability information an exception is raised because of parsing errors, it handles the exception by printing a line of information to the console.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptSuiteRegistry.hInstance Methods
aeteResource:
Returns an NSData object that contains data in 'aete' resource format describing the scriptability information currently known to the application.
Discussion
This method is typically invoked to implement the get aete Apple event for an application that provides scriptability information in the script suite format. The languageName argument is the name of a language for which a localized resource directory (such as English.lproj) exists. This language indication specifies the set of .scriptTerminology files to be used to generate the data. NSScriptSuiteRegistry does not create an 'aete' resource unless this method is called.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptSuiteRegistry.happleEventCodeForSuite:
Returns the Apple event code associated with the suite named suiteName, such as ‘core’ for the Core suite.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptSuiteRegistry.hbundleForSuite:
Returns the bundle containing the suite-definition property list (extension .scriptSuite) identified by suiteName.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptSuiteRegistry.hclassDescriptionsInSuite:
Returns the class descriptions contained in the suite identified by suiteName.
Discussion
Each class description (instance of NSScriptClassDescription) in the returned dictionary is identified by class name.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptSuiteRegistry.hclassDescriptionWithAppleEventCode:
Returns the class description associated with the given four-character Apple event code, code.
Discussion
Overriding behavior is important here. Multiple classes can have the same code if the classes have an uninterrupted linear inheritance from one another. For example, if class B is a subclass of A and class C is a subclass of B, and all three classes have the same four-character Apple event code, then this method returns the class description for class C.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptSuiteRegistry.hcommandDescriptionsInSuite:
Returns the command descriptions contained in the suite identified by suiteName.
Discussion
Each command description (instance of NSScriptCommandDescription) in the returned dictionary is identified by command name.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptSuiteRegistry.hcommandDescriptionWithAppleEventClass:andAppleEventCode:
Returns the command description identified by a suite’s four-character Apple event code of the class (eventClass) and the four-character Apple event code of the command (commandCode).
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptSuiteRegistry.hloadSuitesFromBundle:
Loads the suite definitions in bundle aBundle, invoking loadSuiteWithDictionary:fromBundle: for each suite found.
Discussion
If errors occur while method is parsing a suite-definition file, the method logs error messages to the console.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptSuiteRegistry.hloadSuiteWithDictionary:fromBundle:
Loads the suite definition encapsulated in dictionary; previously, this suite definition was parsed from a .scriptSuite property list contained in a framework or in bundle.
Discussion
The method extracts information from the dictionary and caches it in various internal collection objects. If keys are missing or values are of the wrong type, it logs messages to the console. It also registers class descriptions and command descriptions. In registering a class description, it invokes the NSClassDescription class method registerClassDescription:forClass:. In registering a command description, it arranges for the Apple event translator to handle incoming Apple events that represent the defined commands.
This method is invoked when the shared instance is initialized and when bundles are loaded at runtime. Prior to invoking it, NSScriptSuiteRegistry creates the dictionary argument from the .scriptSuite property list. If you invoke this method in your code, you should try to do it before the application receives its first Apple event.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptSuiteRegistry.hregisterClassDescription:
Registers class description classDescription for use by Cocoa’s built-in scripting support by storing it in a per-suite internal dictionary under the class name.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptSuiteRegistry.hregisterCommandDescription:
Registers command description commandDesc for use by Cocoa’s built-in scripting support by storing it in a per-suite internal dictionary under the command name.
Discussion
Also registers with the single, shared instance of NSAppleEventManager to handle incoming Apple events that should be handled by the command.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptSuiteRegistry.hsuiteForAppleEventCode:
Returns the name of the suite definition associated with the given four-character Apple event code, code.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptSuiteRegistry.hsuiteNames
Returns the names of the suite definitions currently loaded by the application.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSScriptSuiteRegistry.h© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-04-10)