<!--
{
  "availability" : [
    "iOS: 18.4.0 -",
    "iPadOS: 18.4.0 -",
    "macOS: 15.4.0 -",
    "tvOS: 18.4.0 -",
    "visionOS: 2.4.0 -",
    "watchOS: 11.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/appEntityIdentifier(forSelectionType:identifier:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewP012_AppIntents_aB0E19appEntityIdentifier16forSelectionType10identifierQrqd__m_0dE00gH0VSgqd__YbctSHRd__lF"
  },
  "title" : "appEntityIdentifier(forSelectionType:identifier:)"
}
-->

# appEntityIdentifier(forSelectionType:identifier:)

Associates the items in a SwiftUI list view with app entities to make them discoverable by Apple Intelligence and Siri.

```
nonisolated func appEntityIdentifier<I>(forSelectionType itemType: I.Type = I.self, identifier: @escaping @Sendable (I) -> EntityIdentifier?) -> some View where I : Hashable
```

## Discussion

Use this modifier to make app entities that describe data in a list discoverable by Apple Intelligence and Siri.
This provides additional context to the system when the list appears onscreen and people scroll through it.

The following example associates a <doc://com.apple.documentation/documentation/SwiftUI/List> view that displays books with an app
entity for each book in the list.

```swift
struct BookListView: View {
   let books: [Book]
   @State private var selection = Set<Book.ID>()
   var body: some View {
       List(selection: $selection) {
           ForEach(books) { book in
               BookView(book.name)
           }
       }
       .appEntityIdentifier(forSelectionType: Book.ID.self) { bookId in
           EntityIdentifier(for: Book.self, identifier: bookId)
       }
   }
 }
```

For more information, refer to <doc:providing-contextual-cues-to-Apple-Intelligence-and-Siri> and
<doc://com.apple.documentation/documentation/AppIntents>.

---

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)