What is the proper way of defining that the row.text is a binding in this case?
As far as I read the docs and watched the sample code, SwiftUI.Table does not give us a quick way to make some cell editable.
One possible solution would be something like this:
(Not sure, if this code would work as expected.)
struct ContentView: View {
@State var data = [
Thing(id: 1, text: "one"),
Thing(id: 2, text: "two"),
Thing(id: 3, text: "three"),
]
var body: some View {
VStack {
Text("Hello, world!")
.padding()
Table(data) {
TableColumn("ID") { row in Text(String(row.id)) }
TableColumn("Text") { row in
//`id` needs to keep the position in `data`
TextEditor(text: $data[row.id-1].text)
}
}
}
}
}
at the end the Thing will also be some dynamic structure not known at compile time
That sounds like you should better stay in the AppKit world a little more, until SwiftUI gives us more convenient ways to write some dynamic things.