I wanted to add the functionality back in where you could check/uncheck items by tapping the checkbox, rather than having to open the edit view and use the toggle.
So I added this line to RowView:
self.$checklistItem.isChecked.toggle()
But got the error:
Dynamic key path member lookup cannot refer to instance method ‘toggle()’
Here is my RowView.swift:
struct RowView: View {
@Binding var checklistItem: ChecklistItem
@ObservedObject var checklist = Checklist()
var body: some View {
NavigationLink(destination: EditChecklistItemView(checklistItem: $checklistItem)) {
HStack {
Text(checklistItem.name)
Spacer()
Text(checklistItem.isChecked ? "✅" : "◻️")
.onTapGesture {
self.$checklistItem.isChecked.toggle()
self.checklist.printChecklistContents()
}
}
}
}
}