<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/RealityViewAttachments/entity(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:19_RealityKit_SwiftUI0A15ViewAttachmentsV6entity3forAA0E16AttachmentEntityCSgx_tSHRzlF"
  },
  "title" : "entity(for:)"
}
-->

# entity(for:)

Gets the identified attachment view as an entity, if the view with that
identifier exists.

```
func entity(for id: some Hashable) -> ViewAttachmentEntity?
```

## Parameters

`id`

The value that you used to tag the view when you
define it in the `attachments` parameter of the [`RealityView`](/documentation/RealityKit/RealityView)
initializer [`init(make:update:attachments:)`](/documentation/RealityKit/RealityView/init(make:update:attachments:)).

## Return Value

The resolved attachment entity, or `nil` if [`RealityView`](/documentation/RealityKit/RealityView)
can’t find an attachment view with the given `id`.

## Discussion

Attachment entities are not automatically added to your
[`RealityView`](/documentation/RealityKit/RealityView)’s content. To display an attachment, add it to your
[`RealityView`](/documentation/RealityKit/RealityView)’s content using a function like
`RealityViewContent/add(_:)`.

---

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)