I have this in my ContentView
:
List {
ForEach(items) { Item in
ItemView(cellColor: self.$cellColor, title: item.title, orderId: "\(item.orderId)")
}
}
I want to update a variable, let's say by adding 1 to it, on each iteration of the loop, but I can't get SwiftUI to do that. Something like this:
var a: Int = 1
List {
ForEach(toDoItems) { toDoItem in
ToDoItemView(cellColor: self.$cellColor, title: toDoItem.title, orderId: "\(toDoItem.orderId)")
a = a + 1
}
}
But that doesn't work. Apologies if I've not asked this in the correct format, This is my first question here!