Вы не должны изменять подпись prepare(for
, иначе она не будет вызвана. Параметр sender
должен быть Any?
Приведите параметр sender
к IndexPath
, и я рекомендую switch
оператор
func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
if segue.identifier == toDetailVCSegue {
let destination = segue.destination as! DetailViewController
let indexPath = sender as! IndexPath
switch indexPath.row {
case 0: destination.itemArray = namesArray
case 1: destination.itemArray = scoresArray
case 2: destination.itemArray = timesArray
case 3: destination.itemArray = completedArray
default: break
}
}
}