这是我的代码,其中出现错误:
错误出现在第 3 行“if let indexpath...”
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "show Detail" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let taakDetail : Taak = taken[(indexPath as NSIndexPath).row]
let controller = (segue.destination as! UINavigationController).topViewController as! DetailsViewController
controller.selectedTaak = taakDetail
}
}
我无法找出这有什么含糊之处。它引用的代码是:
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return taken.count
}
就是没找到tableView
,因此假设您以某种方式打算引用此方法(显然您没有),因此会被抛弃。
请注意,您的插座是tableview
, not tableView
。属性区分大小写。
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "show Detail" {
if let indexPath = self.tableview.indexPathForSelectedRow {
let taakDetail : Taak = taken[indexPath.row]
let controller = (segue.destination as! UINavigationController).topViewController as! DetailsViewController
controller.selectedTaak = taakDetail
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)