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

# object(withID:)

Returns the object in the array with the given identifier.

```
func object(withID identifier: Any) -> Any
```

## Parameters

`identifier`

The identifier of one of the receiver’s objects.

## Return Value

A reference to the identified object or `nil` if could not be
found.

## Discussion

This method is provided as an alternative to
<doc://com.apple.documentation/documentation/Foundation/NSArray/object(at:)>
for applications where an identifier is available instead of (or in addition
to) an index. A unique ID is generally more stable than an index. For
example, it may be more useful to identify a contact in Address Book by its
identifier (which doesn’t change over time) than by its index in the list of
contacts (which can change as contacts are added or removed).

---

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)