这是我的代码,其中出现错误:
如果让indexpath …’,则错误在第3行’
如果让indexpath …’,则错误在第3行’
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,而不是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 } } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。