Mac Developer Library

Developer

Foundation Framework Reference NSScriptSuiteRegistry Class Reference

Options
Deployment Target:

On This Page
Language:

NSScriptSuiteRegistry

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.

Inheritance


Conforms To


Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in OS X v10.0 and later.
  • Sets the single, shared instance of NSScriptSuiteRegistry to registry.

    Declaration

    Swift

    class func setSharedScriptSuiteRegistry(_ registry: NSScriptSuiteRegistry)

    Objective-C

    + (void)setSharedScriptSuiteRegistry:(NSScriptSuiteRegistry *)registry

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the single, shared instance of NSScriptSuiteRegistry, creating it first if it doesn’t exist.

    Declaration

    Swift

    class func sharedScriptSuiteRegistry() -> NSScriptSuiteRegistry

    Objective-C

    + (NSScriptSuiteRegistry *)sharedScriptSuiteRegistry

    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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the name of the suite definition associated with the given four-character Apple event code, code.

    Declaration

    Swift

    func suiteForAppleEventCode(_ appleEventCode: FourCharCode) -> String?

    Objective-C

    - (NSString *)suiteForAppleEventCode:(FourCharCode)appleEventCode

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

    See Also

    – suiteNames

  • Returns the names of the suite definitions currently loaded by the application.

    Declaration

    Swift

    var suiteNames: [AnyObject] { get }

    Objective-C

    @property(readonly, copy) NSArray *suiteNames

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns an NSData object that contains data in 'aete' resource format describing the scriptability information currently known to the application.

    Declaration

    Swift

    func aeteResource(_ languageName: String) -> NSData?

    Objective-C

    - (NSData *)aeteResource:(NSString *)languageName

    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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the Apple event code associated with the suite named suiteName, such as ‘core’ for the Core suite.

    Declaration

    Swift

    func appleEventCodeForSuite(_ suiteName: String) -> FourCharCode

    Objective-C

    - (FourCharCode)appleEventCodeForSuite:(NSString *)suiteName

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the bundle containing the suite-definition property list (extension .scriptSuite) identified by suiteName.

    Declaration

    Swift

    func bundleForSuite(_ suiteName: String) -> NSBundle?

    Objective-C

    - (NSBundle *)bundleForSuite:(NSString *)suiteName

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • 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.

    Declaration

    Swift

    func loadSuiteWithDictionary(_ suiteDeclaration: [NSObject : AnyObject], fromBundle bundle: NSBundle)

    Objective-C

    - (void)loadSuiteWithDictionary:(NSDictionary *)suiteDeclaration fromBundle:(NSBundle *)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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Loads the suite definitions in bundle aBundle, invoking loadSuiteWithDictionary:fromBundle: for each suite found.

    Declaration

    Swift

    func loadSuitesFromBundle(_ bundle: NSBundle)

    Objective-C

    - (void)loadSuitesFromBundle:(NSBundle *)bundle

    Discussion

    If errors occur while method is parsing a suite-definition file, the method logs error messages to the console.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.