I've created a Swift array that contains collections of two instances of a custom data type:
var myArray : [(MyDataType, MyDataType)]!
When I want to add items to this array, it's trivial to do so with the following code (where firstVar
and secondVar
are instances of MyDataType
)
myArray.append((firstVar, secondVar))
What I'm currently struggling with is removing items from myArray
. Using this code, I get an error of Value of type '[(MyDataType, MyDataType)]' has no member 'indexOf'
:
let indexOfA = myArray.indexOf((firstVar, secondVar))
myArray.remove(at: indexOfA)
Honestly somewhat confused, so any help as to how to get the index of an item of (MyDataType, MyDataType)
so that I can then remove it from myArray
would be extremely helpful!