Open onmyway133 opened 2 years ago
Note that
id
selection
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) } }
Note that
id
is needed, although Book already conforms to Identifiableselection
needs a default value