I would like to implement feature that if profileImage tapped in tableviewCell, segue to detailView. I add tapGesture but I still can't figure out how to get indexPath to pass data. I tried like this but app will crash.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "detailSegue" {
let next: DetailViewController = segue.destination as! DetailViewController
// pattern1
let indexPath = tableView.indexPath(for: sender as! CustomTableViewCell)
// pattern2
let indexPath = tableView.indexPathForSelectedRow! as NSIndexPath
next.data = datas[indexPath.row]
}
}
How can I fix this? Thank you in advance!