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

# SBObject

The `SBObject` class declares methods that can be invoked on any object in a
scriptable application. It defines methods for getting elements and
properties of an object, as well as setting a given object to a new value.

```
class SBObject
```

## Overview

Each `SBObject` is built around an object specifier, which tells Scripting
Bridge how to locate the object. Therefore, you can think of an `SBObject`
as a reference to an object in an target application rather than an object
itself. To bypass this reference-based approach and force evaluation, use
the [`get()`](/documentation/ScriptingBridge/SBObject/get()) method.

Typically, rather than create `SBObject` instances explictly, you receive
`SBObject` objects by calling methods of an [`SBApplication`](/documentation/ScriptingBridge/SBApplication) subclass. For
example, if you wanted to get an `SBObject` representing the current iTunes
track, you would use code like this (where `iTunesTrack` is a subclass of
`SBObject`):

```objc
iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
iTunesTrack *track = [iTunes currentTrack];
```

You can discover the names of dynamically generated classes such as
`iTunesApplication` and `iTunesTrack` by examining the header file created
by the `sdp` tool. Alternatively, you give these variables the dynamic
Objective-C type `id`.

## Topics

### Initializing a Scripting Bridge Object

[`init()`](/documentation/ScriptingBridge/SBObject/init())

Initializes and returns an instance of an `SBObject` subclass.

[`init(data:)`](/documentation/ScriptingBridge/SBObject/init(data:))

Returns an instance of an `SBObject` subclass initialized with the given
data.

[`init(properties:)`](/documentation/ScriptingBridge/SBObject/init(properties:))

Returns an instance of an `SBObject` subclass initialized with the specified
properties.

[`init(elementCode:properties:data:)`](/documentation/ScriptingBridge/SBObject/init(elementCode:properties:data:))

Returns an instance of an `SBObject` subclass initialized with the specified
properties and data and added to the designated element array.

### Getting Referenced Data

[`get()`](/documentation/ScriptingBridge/SBObject/get())

Forces evaluation of the receiver, causing the real object to be returned
immediately.

### Sending Apple Events

[`sendEvent:id:parameters:`](/documentation/ScriptingBridge/SBObject/sendEvent:id:parameters:)

Sends an Apple event with the given event class, event ID, and format to the
target application.

[`setTo(_:)`](/documentation/ScriptingBridge/SBObject/setTo(_:))

Sets the receiver to a specified value.

### Getting Properties and Elements

[`property(with:code:)`](/documentation/ScriptingBridge/SBObject/property(with:code:))

Returns an object of the designated scripting class representing the
specified property of the receiver

[`property(withCode:)`](/documentation/ScriptingBridge/SBObject/property(withCode:))

Returns an object representing the specified property of the receiver.

[`elementArray(withCode:)`](/documentation/ScriptingBridge/SBObject/elementArray(withCode:))

Returns an array containing every child of the receiver with the given
class-type code.



---

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)