我想从tableview导航到不同的ViewController
这里是我编写的代码我想要的值存储在我的模型类中的不同视图控制器中我需要它们这里是我的代码写的它给了我
致命错误:索引超出范围
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
switch(indexPath.row)
{
case 0 : let v1 = self.storyboard?.instantiateViewController(withIdentifier: "pass1") as! ViewControllerngodetails
v1.t = arrayNGO[indexPath.row]
navigationController?.pushViewController(v1, animated: true)
break;
case 1 : let v2 = self.storyboard?.instantiateViewController(withIdentifier: "pass2") as! ViewController2Reg
v2.e = arrayNGO[indexPath.row]
navigationController?.pushViewController(v2, animated: true)
break;
case 2 : let v3 = self.storyboard?.instantiateViewController(withIdentifier: "pass3") as! ViewController3FCRA
v3.t = arrayNGO[indexPath.row]
navigationController?.pushViewController(v3, animated: true)
break;
case 3 : let v4 = self.storyboard?.instantiateViewController(withIdentifier: "pass4") as! ViewControllersectorkeys
v4.t = arrayNGO[indexPath.row]
navigationController?.pushViewController(v4, animated: true)
case 4 : let v5 = self.storyboard?.instantiateViewController(withIdentifier: "pass5") as! ViewController5contactdet
v5.t = arrayNGO[indexPath.row]
navigationController?.pushViewController(v5, animated: true)
case 5 : let v6 = self.storyboard?.instantiateViewController(withIdentifier: "pass6") as! ViewController6bnkdetails
v6.t = arrayNGO[indexPath.row]
navigationController?.pushViewController(v6, animated: true)
default: break
}
答案 0 :(得分:0)
尝试在某行上打印arrayNGO.count以了解数组的确切值
在switch语句之前添加此行以了解您的代码。
print(arrayNGO.count)