Suppose I have an array:
var intArray: [Int] = [1,2,3,4,5] {
didSet{
//print index of value that was modified
}
}
if I do intArray[2] = 10
, what can I write inside didSet
in order to print the index of the modified value (2, in this case) ?
The zip() function could be useful for this:
It also works for single element changes but arrays are subject to multiple changes so its safer to get an array of changed indexes.