Use enumerated
and id: \.element.title
struct TodoListView: View {
let todos: [Todo]
var body: some View {
// Create New Object with Index
let withIndex = todos.enumerated().map({ $0 })
return List(withIndex, id: \.element.title) { index, todo in
NavigationLink(
destination: TodoDetailView(todo: todo),
label: {
VStack(alignment: .leading) {
Text(todo.title)
.styleMultiline()
}
.paddingVertically()
}
)
}
}
}