<!--
{
  "availability" : [
    "macOS: 13.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/List/init(_:id:editActions:selection:rowContent:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ListV_2id11editActions9selection10rowContentACyxAA7ForEachVyAA27IndexedIdentifierCollectionVyqd__qd_0_Gqd_0_AA08EditablenI0Vyqd_1_qd__GGGAA7BindingVyqd__G_s7KeyPathCy7ElementSTQyd__qd_0_GAA04EditF0Vyqd__GASyxGqd_1_ASyAXGctcAPRs_SMRd__SkRd__SHRd_0_AA4ViewRd_1_SH5IndexSlRpd__r1_lufc::OverloadGroup"
  },
  "title" : "init(_:id:editActions:selection:rowContent:)"
}
-->

# init(_:id:editActions:selection:rowContent:)

Creates a list that computes its rows on demand from an underlying
collection of identifiable data, enables editing the collection, and
requires a selection of a single row.

```
nonisolated init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, editActions: EditActions<Data>, selection: Binding<SelectionValue>, @ContentBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<IndexedIdentifierCollection<Data, ID>, ID, EditableCollectionContent<RowContent, Data>>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View, Data.Index : Hashable
```

## Parameters

`data`

The identifiable data for computing and to be edited by
the list.

`id`

The key path to the data model’s identifier.

`editActions`

The edit actions that are synthesized on `data`.

`selection`

A binding to a non optional selected value.

`rowContent`

A content builder that creates the view for a single row of

## Discussion

The following example creates a list to display a collection of favorite
foods allowing the user to delete or move elements from the
collection, and selects a single row.

```
List(
    $foods,
    editActions: [.delete, .move],
    selection: $selectedFood
) { $food in
   HStack {
       Text(food.name)
       Toggle("Favorite", isOn: $food.isFavorite)
   }
}
```

Use [`deleteDisabled(_:)`](/documentation/SwiftUI/View/deleteDisabled(_:)) and [`moveDisabled(_:)`](/documentation/SwiftUI/View/moveDisabled(_:))
to disable respectively delete or move actions on a per-row basis.

Explicit [`onDelete(perform:)`](/documentation/SwiftUI/DynamicViewContent/onDelete(perform:)),
[`onMove(perform:)`](/documentation/SwiftUI/DynamicViewContent/onMove(perform:)), or
[`swipeActions(edge:allowsFullSwipe:content:)`](/documentation/SwiftUI/View/swipeActions(edge:allowsFullSwipe:content:))
modifiers override any synthesized action.

---

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)