tableviewセルのindexPath.rowを、あるviewControllerから別のviewControllerに分割したいと思っています。テーブルビューのセルからデータを渡す方法
var index = 0
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
index = indexPath.row
performSegue(withIdentifier: "cellIndex", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.destination is trackSavingViewController{
let TSController = segue.destination as! trackSavingViewController
TSController.indexCell = index
}
}
しかし、すべては、選択された行の値ではなく、元の値(インデックス= 0)を単に通過しているだけです。コードを修正するにはどうすればよいですか?
それは言う、「未解決識別子 『テーブルビュー』の使用」 –
リンクあなたのテーブルビューをあなたのViewControllerクラスにまたはあなたはそれをそれが動作 – Sherman
を命名するとき、あなたのテーブルビューには、別の名前を持っています!どうもありがとうございます;) –