我正在研究Swift,我在tableview的didSelectRowAtIndexPath方法中遇到了错误.我想将值传递给另一个视图控制器,即'secondViewController'.这里EmployeesId是一个数组.相关代码如下:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
var view: Dashboard = self.storyboard?.instantiateViewControllerWithIdentifier("Dashboard") as Dashboard
self.navigationController?.pushViewController(view, animated: true)
secondViewController.UserId = employeesId[indexPath.item] //getting an error here.
}
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:致命错误:在展开Optional值时意外发现nil.
任何帮助将不胜感激.