Trying to learn Swift and SwiftUI, but I'm not happy about it.
I have a data model:
class File : Identifiable, Hashable, CustomStringConvertible {
var edited:Bool = false;
}
The SwiftUI view has a column that shows the edited value as either blank or the pencil system image:
public var body: some View {
NavigationSplitView {
Table(of:File.self, selection:$selection) {
TableColumn("Edited") { fyl in
if fyl.edited {
SwiftUI.Label("", systemImage:"pencil")
.font(.system(size:8, weight:.heavy))
}
}
}
rows: {
etc…
However, when an edited value is set to true, the table doesn't update. I have to manually click on the row to make it redraw. Since SwiftUI doesn't have the convenience of letting me assign the Table to a property and then calling reloadData like NSTableView does, I'm not sure what to do. I've read things about @ObservableObject and such, but I'm not sure I understand where it goes, and when I try it on the edited property I get a syntax error. Any help?