Это работало:
ForEach(todoLists, id: \.self) {todoList in
NavigationLink(destination: TodoItemView(todoList: todoList), label: {
HStack {
if (todoList.countChecked == todoList.countTotal) {
Text(todoList.title!)
.foregroundColor(stringToColor(string: todoList.color!))
.strikethrough()
}
else {
Text(todoList.title!)
.foregroundColor(stringToColor(string: todoList.color!))
}
Spacer()
Text(String(todoList.countChecked) + " / " + String(todoList.countTotal))
.foregroundColor(.gray)
.font(.footnote)
}
})
}
Так что я переместил часть этого в свою собственную структуру View, потому что компилятор Xcode начал spazzing:
struct TodoListLabel: View {
var todoList: TodoList
var body: some View {
HStack {
if (todoList.countChecked == todoList.countTotal) {
Text(todoList.title!)
.foregroundColor(stringToColor(string: todoList.color!))
.strikethrough()
}
else {
Text(todoList.title!)
.foregroundColor(stringToColor(string: todoList.color!))
}
Spacer()
Text(String(todoList.countChecked) + " / " + String(todoList.countTotal))
.foregroundColor(.gray)
.font(.footnote)
}
}
}
Теперь у меня есть это:
ForEach(todoLists, id: \.self) {todoList in
NavigationLink(destination: TodoItemView(todoList: todoList), label: {
TodoListLabel(todoList: todoList)
})
}
Проблема в том, что, поскольку я переместил его в свою собственную структуру View, симулятор больше не отображает изменения в списке, как это было раньше, когда я вносил изменения в список или любые его связи.