I'll keep it simple, I have a List with UUID identified items. This list is selectable, when EditMode() is entered user can tap items, and these get added to the selection variable:
And the selection variable is:
@State var selection = Set<UUID?>()
However, the issue is that I care about the order in which the items are selected. And in the selection array, the items are not updated in a FIFO or LIFO way, they seem to be random or perhaps it depends on the value of the UUID but the point is it doesn't conserve the order in which they are added.
I considered using a stack to keep track of what is added, but the List + selection combination in SwiftUI doesn't appear to have built in methods to inform of new additions e.g. UUID 1234 has been added. I can thing of "not clean" ways to make it work like iterating through the whole selection Set every time selection.count
changes and add the "new item" to the stack but I wouldn't want to come down to that.