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

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

```
init(elementCode code: DescType, properties: [String : Any]?, data: Any?)
```

## Parameters

`code`

A four-character code used to identify an element in the target
application’s scripting interface. See
<doc://com.apple.documentation/documentation/applicationservices/apple_event_manager>
for details.

`properties`

A dictionary with <doc://com.apple.documentation/documentation/Foundation/NSNumber> keys specifying the four-character codes of properties
(that is, attributes or to-one relationships) and the values for those
properties. Pass `nil` if you are initializing the object by `data` only.

`data`

An object containing data for the new `SBObject` object. The data
varies according to the type of scripting object to be created. Pass `nil`
if you initializing the object by `properties` only.

## Return Value

An `SBObject` object or `nil` if the object could not be
initialized.

## Discussion

Unlike the other initializers of this class, this method not only
initializes the `SBObject` object but adds it to a specified element array.
This method is the designated initializer.

---

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)