Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)' Why this error?
Asked Answered
L

1

10

Here is my code in which the error appears: The error is in line 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
        }
    }

I can't find out what is ambiguous about this. The code to which it refers to is:

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return taken.count
}
Lindner answered 20/10, 2016 at 20:47 Comment(3)
Show us how your variables are defined.Pharaoh
Possible duplicate of Getting error Ambiguous use of tableView(_:numberOfRowsInSection:)Answerable
My IBOutlet = @IBOutlet weak var tableview: UITableView!Lindner
O
11

It's not finding tableView, and is therefore getting thrown off, assuming you somehow meant to reference this method (which you don't, obviously).

Note, your outlet is 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
        }
    }
}
Outstation answered 20/10, 2016 at 22:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.