我有两个不同的ViewControllers,细节&搜索。去细节的赛段工作正常,但去搜索一直不断崩溃的应用程序。我已经花了两个小时阅读类似的问题,但没有人似乎有同样的问题:Xcode Segue“无法投射类型的值”
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let detailVC = segue.destination as! DetailViewController
if segue.identifier == "newDocSegue" {
// Create a new document and pass it to the detail view.
detailVC.doc = Document()
detailVC.isAddAction = true
}
if segue.identifier == "editDocSegue" {
// Load the existing document into the detail view, for editing.
let indexPath = tableView.indexPath(for: sender as! UITableViewCell)!
detailVC.doc = Document[indexPath.row]
detailVC.isAddAction = false
}
else if segue.identifier == "searchSegue" {
shouldPerformSegue(withIdentifier: "searchSegue", sender: Any?.self)
}
}
segues从TableViewController到ViewControllers –
shouldPerformSegue(withIdentifier:“searchSegue”,sender:Any?.self),为什么这行代码在那里? – raki
您在第二个if语句中缺少'else' – Fonix