Issue #878
Note that
- Explicit
id
is needed, although Book already conforms to Identifiable selection
needs a default value
class BookViewModel: ObservableObject {
@Published var books: [Book] = []
@Published var selectedBooks: Set<Book> = []
}
List(selection: $viewModel.selectedBooks) {
ForEach(viewModel.books, id: \.self) { book in
BookRow(book: book)
}
}