Ambiguous reference to tableView element (_: numberOfRowsInSection :) "Why is this error?

Here is my code where the error appears: The error is on line 3 'if the pathpath ... pointer

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
        }
    }

I cannot find out what is ambiguous in this. The code to which it refers is:

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return taken.count
}
+4
source share
1 answer

It does not find tableView, and therefore it is discarded, suggesting that you somehow wanted to refer to this method (which you do not see, obviously).

Please note: your outlet tableView, not tableView. Properties are case sensitive.

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
        }
    }
}
+4
source

Source: https://habr.com/ru/post/1658375/


All Articles