I am trying to update the values in an array of arrays but I guess the for item in buffer must be making a copy of the item in the buffer rather than providing a reference to the original item. Is there any way to do this other than some kind of for i=...{buffer[i][3]='Moved'}.
var buffer = [[String]]()
let bufRemoved = buffer.filter({$0[3] == "Removal"})
let bufAdded = buffer.filter({$0[3] == "Addition"})
let moved = bufRemoved.filter({item in bufAdded.contains(where: {$0[2] == item[2]})})
for var item in buffer {
if moved.contains(where: {$0[2] == item[2]}) {
switch item[3] {
case "Removal":
item[3] = "Moved(out)"
case "Addition":
item[3] = "Moved(in)"
default:
break
}
}
}
let bufMoved = buffer.filter({$0[3].contains("Move")})
for i in buffer.indicesis the way to go.updatedBufferarray, adding every item to it inside the for loop, which can be used onwards.