---
title: "object(withName:)"
framework: Scripting Bridge
role: symbol
role_heading: Instance Method
platforms: [Mac Catalyst 13.0+, macOS 10.5+]
path: "scriptingbridge/sbelementarray/object(withname:)"
---

# object(withName:)

Returns the object in the array with the given name.

## Declaration

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

## Parameters

- `name`: The name of one of the receiver’s objects.

## Return Value

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

## Discussion

Discussion This method is provided as an alternative to 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.

## See Also

### Getting Objects in the Array

- [object(withID:)](scriptingbridge/sbelementarray/object(withid:).md)
- [object(atLocation:)](scriptingbridge/sbelementarray/object(atlocation:).md)
