---
title: "init(elementCode:properties:data:)"
framework: Scripting Bridge
role: symbol
role_heading: Initializer
platforms: [Mac Catalyst 13.0+, macOS 10.5+]
path: "scriptingbridge/sbobject/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.

## Declaration

```swift
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

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

## Discussion

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.

## See Also

### Initializing a Scripting Bridge Object

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