I'm trying to use the indexOf to know the index of an object inside the array but I do not know which parameter (s) to pass.
My code:
/// Struct that define the track model
I'm trying to use the indexOf to know the index of an object inside the array but I do not know which parameter (s) to pass.
My code:
/// Struct that define the track model
You have to specify which property you want to compare, as in your example the only property with a unique value is the name, I used it to compare.
if let index = playlist.tracks.indexOf({$0.songName == t.songName}){
print(index)
}
Functional example : link