If i have an array like this:
@State private var names = ["Steve", "Bill", "Elon", "Jeff", "Michael"]
and i remove its items onAppear, how can i get the original names.count
value despite the elements being removed?
I tried creating a copy this way: var namesCopy = names
but it’s just a reference and i ended up with 2 variables referencing the same array
2
Answers
We can use original as separated storage, like
and filter to set
names
as we needYou’d have something like this: