---
title: SBObject
framework: Scripting Bridge
role: symbol
role_heading: Class
platforms: [Mac Catalyst 13.0+, macOS 10.5+]
path: scriptingbridge/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.

## Declaration

```swift
class SBObject
```

## Overview

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() method. Typically, rather than create SBObject instances explictly, you receive SBObject objects by calling methods of an 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): 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()](scriptingbridge/sbobject/init().md)
- [init(data:)](scriptingbridge/sbobject/init(data:).md)
- [init(properties:)](scriptingbridge/sbobject/init(properties:).md)
- [init(elementCode:properties:data:)](scriptingbridge/sbobject/init(elementcode:properties:data:).md)

### Getting Referenced Data

- [get()](scriptingbridge/sbobject/get().md)

### Sending Apple Events

- [setTo(_:)](scriptingbridge/sbobject/setto(_:).md)

### Getting Properties and Elements

- [property(with:code:)](scriptingbridge/sbobject/property(with:code:).md)
- [property(withCode:)](scriptingbridge/sbobject/property(withcode:).md)
- [elementArray(withCode:)](scriptingbridge/sbobject/elementarray(withcode:).md)

### Initializers

- [init(coder:)](scriptingbridge/sbobject/init(coder:).md)

### Instance Methods

- [lastError()](scriptingbridge/sbobject/lasterror().md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [SBApplication](scriptingbridge/sbapplication.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
