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

# object(withName:)

Returns the object in the array with the given name.

```
func object(withName name: String) -> Any
```

## Parameters

`name`

The name of one of the receiver’s objects.

## Return Value

A reference to the designated object or `nil` if the object
couldn’t be found.

## Discussion

This method is provided as an alternative
to <doc://com.apple.documentation/documentation/Foundation/NSArray/object(at:)>
for applications where a name is available instead of (or in addition to) an
index. A name is generally more stable than an index. For example, it is
typically more useful to identify a mailbox in Mail by its name than by its
index in the list of mailboxes.

---

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)