<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Scripting Bridge",
  "identifier" : "/documentation/ScriptingBridge/SBApplication",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Scripting Bridge"
    ],
    "preciseIdentifier" : "c:objc(cs)SBApplication"
  },
  "title" : "SBApplication"
}
-->

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

```
class SBApplication
```

## 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:

```objc
[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:`](/documentation/ScriptingBridge/SBApplication/applicationWithBundleIdentifier:)

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

[`applicationWithProcessIdentifier:`](/documentation/ScriptingBridge/SBApplication/applicationWithProcessIdentifier:)

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

[`applicationWithURL:`](/documentation/ScriptingBridge/SBApplication/applicationWithURL:)

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

### Initializing a Scriptable Application Object

[`init(bundleIdentifier:)`](/documentation/ScriptingBridge/SBApplication/init(bundleIdentifier:))

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

[`init(processIdentifier:)`](/documentation/ScriptingBridge/SBApplication/init(processIdentifier:))

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

[`init(url:)`](/documentation/ScriptingBridge/SBApplication/init(url:)-6xbe5)

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

### Creating a Scripting Class

[`class(forScriptingClass:)`](/documentation/ScriptingBridge/SBApplication/class(forScriptingClass:))

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

### Controlling the Application

[`activate()`](/documentation/ScriptingBridge/SBApplication/activate())

Moves the target application to the foreground immediately.

[`isRunning`](/documentation/ScriptingBridge/SBApplication/isRunning)

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

[`launchFlags`](/documentation/ScriptingBridge/SBApplication/launchFlags)

The launch flags for the application represented by the receiver.

[`sendMode`](/documentation/ScriptingBridge/SBApplication/sendMode)

The mode for sending Apple events to the target application.

[`timeout`](/documentation/ScriptingBridge/SBApplication/timeout)

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

### Getting Class Names and Codes

### Managing the Delegate

[`delegate`](/documentation/ScriptingBridge/SBApplication/delegate)

The error-handling delegate of the receiver.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)