For example i have an array
var array = [1, 2, 3, 4]
I want to remove item at index 1 then at index 3 "let it be in a for loop".
But removing the item at index 1 will move the item at index 3 to index 2, thus messing up the second removal.
Any suggestions ?
It's simple. delete items from the end.
First delete 3 and after that delete 1
Swift 3: Use swift closure to perform the same operation.
If your array is like
and indexes you want to remove
Swift 3: Here is same operation with JSON Object (dictionary)
Given your array
and a
Set
of indexes you want to removeJust write
Result