Class

SBApplication

The SBApplication class provides a mechanism enabling an Objective-C program to send Apple events to a scriptable application and receive Apple events in response. It thereby makes it possible for that program to control the application and exchange data with it. Scripting Bridge works by bridging data types between Apple event descriptors and Cocoa objects.

Declaration

@interface SBApplication : SBObject

Overview

Although SBApplication includes methods that manually send and process Apple events, you should never have to call these methods directly. Instead, subclasses of SBApplication implement application-specific methods that handle the sending of Apple events automatically.

For example, if you wanted to get the current iTunes track, you can simply use the currentTrack method of the dynamically defined subclass for the iTunes application—which handles the details of sending the Apple event for you—rather than figuring out the more complicated, low-level alternative:

[iTunes propertyWithCode:'pTrk'];

If you do need to send Apple events manually, consider using the NSAppleEventDescriptor class.

Subclassing Notes

You rarely instantiate SBApplication objects directly. Instead, you get the shared instance of a application-specific subclass typically by calling one of the applicationWith... class methods, using a bundle identifier, process identifier, or URL to identify the application.

Topics

Getting a Scriptable Application Instance

+ applicationWithBundleIdentifier:

Returns the shared instance representing the target application specified by its bundle identifier.

+ applicationWithProcessIdentifier:

Returns the shared instance representing a target application specified by its process identifier.

+ applicationWithURL:

Returns the shared instance representing a target application specified by the given URL.

Initializing a Scriptable Application Object

- initWithBundleIdentifier:

Returns an instance of an SBApplication subclass that represents the target application identified by the given bundle identifier.

- initWithProcessIdentifier:

Returns an instance of an SBApplication subclass that represents the target application identified by the given process identifier.

- initWithURL:

Returns an instance of an SBApplication subclass that represents the target application identified by the given URL.

Creating a Scripting Class

- classForScriptingClass:

Returns a class object that represents a particular class in the target application.

Controlling the Application

- activate

Moves the target application to the foreground immediately.

running

A Boolean that indicates whether the target application represented by the receiver is running

launchFlags

The launch flags for the application represented by the receiver.

sendMode

The mode for sending Apple events to the target application.

timeout

The period the application will wait to receive reply Apple events.

Getting Class Names and Codes

- classNamesForCodes

Returns a dictionary mapping four-character class codes to the names of their corresponding Objective-C classes.

- codesForPropertyNames

Returns a dictionary mapping property keys to their corresponding four-character codes.

Managing the Delegate

delegate

The error-handling delegate of the receiver.

Relationships

Inherits From

Conforms To