It easy to create a simple list like this:
List { Text("Item 1") Text("Item 2") Text("Item3") }
But how I can add a selection like traditional NSTable?
struct names {
var id = 0
var name = ""
}
var demoData = ["Phil Swanson", "Karen Gibbons", "Grant Kilman", "Wanda Green"]
struct SelectionDemo : View {
@State var selectKeeper = Set<String>()
var body: some View {
HStack {
List(demoData, id: \.self, selection: $selectKeeper){ name in
Text(name)
}.frame(width: 500, height: 460)
}
}
}
#if DEBUG
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
SelectionDemo()
}
}
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With