Class

NSScript​Class​Description

An instance of NSScript​Class​Description describes a script class that a Cocoa application supports.

Overview

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 NSScript​Suite​Registry. The registry object creates an NSScript​Class​Description 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 NSScript​Class​Description. However, one case where you might need access to a class description is if you override object​Specifier 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 indices​Of​Objects​By​Evaluating​With​Container:​count:​ in a specifier class.

Although you can subclass NSScript​Class​Description, it is unlikely that you would need to do so, or even to create instances of it.

Symbols

Initializing a Script Class Description

init?(suite​Name:​ String, class​Name:​ String, dictionary:​ [Any​Hashable :​ Any]?)

Initializes and returns a newly allocated instance of NSScript​Class​Description.

Getting a Script Class Description

init?(for:​ Any​Class)

Returns the class description for the specified class or, if it is not scriptable, for the first superclass that is.

func for​Key(String)

Returns the class description instance for the class type of the specified attribute or relationship.

var superclass:​ NSScript​Class​Description?

Returns the class description instance for the superclass of the receiver’s class.

Getting basic information about the script class

var class​Name:​ String?

Returns the name of the class the receiver describes, as provided at initialization time.

var default​Subcontainer​Attribute​Key:​ String?

Returns the value of the Default​Subcontainer​Attribute entry of the class dictionary from which the receiver was instantiated.

var implementation​Class​Name:​ String?

Returns the name of the Objective-C class instantiated to implement the scripting class.

func is​Location​Required​To​Create(for​Key:​ String)

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.

var suite​Name:​ String?

Returns the name of the receiver’s suite.

Getting and comparing Apple event codes

var apple​Event​Code:​ Four​Char​Code

Returns the Apple event code associated with the receiver’s class.

func apple​Event​Code(for​Key:​ String)

Returns the Apple event code for the specified attribute or relationship in the receiver.

func matches​Apple​Event​Code(Four​Char​Code)

Returns a Boolean value indicating whether a primary or secondary Apple event code in the receiver matches the passed code.

Getting attribute and relationship information

func has​Ordered​To​Many​Relationship(for​Key:​ String)

Returns a Boolean value indicating whether the described class has an ordered to-many relationship identified by the specified key.

func has​Property(for​Key:​ String)

Returns a Boolean value indicating whether the described class has a property identified by the specified key.

func has​Readable​Property(for​Key:​ String)

Returns a Boolean value indicating whether the described class has a readable property identified by the specified key.

func has​Writable​Property(for​Key:​ String)

Returns a Boolean value indicating whether the described class has a writable property identified by the specified key.

func key(with​Apple​Event​Code:​ Four​Char​Code)

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.

func type(for​Key:​ String)

Returns the name of the declared type of the attribute or relationship identified by the passed key.

Getting command information

func selector(for​Command:​ NSScript​Command​Description)

Returns the selector associated with the receiver for the specified command description.

func supports​Command(NSScript​Command​Description)

Returns a Boolean value indicating whether the receiver or any superclass supports the specified command.

Relationships