Getting Error Ambiguous Use of Tableview(_:Numberofrowsinsection:)

Getting error Ambiguous use of tableView(_:numberOfRowsInSection:)

I've had a similar problem after upgrading to Xcode 7.1 beta. I wonder if this is a bug in the beta? has anyone found a solution?

so i solved this issue in my project. I had to set the IBOutlet for my tableView and then do the reloadData on that object. e.g. set IBOutlet to myItemsTableView then call self.myItemsTableView.reloadData() and that worked fine. On this project it needed myItemsTableView and reload on that rather than then generic command tableView.reloadData().

hope that helps.

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

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

Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)'

The problem is that there is nothing in your view controller called self.tableView. Its name is completedCaseTableView. So change this:

if let indexPath = self.tableView.indexPathForSelectedRow {

to this:

if let indexPath = self.completedCaseTableView.indexPathForSelectedRow {

tableView.reloadData() error: Ambiguous reference to member

You don't have an outlet called tableView. Create one, connect it to Interface Builder and you should be fine.

Ambiguous reference to member 'tableView(_:didSelectRowAt:)' (Swift)

You are missing the @IBOutlet for your tableView. So when you reference self.tableView Swift thinks you are talking about one of the methods that starts with tableView.

So, get rid of this line in searchBar(_:textDidChange:):

let tableView = UITableView()

and add an outlet to your tableView and connect it:

@IBOutlet weak var tableView: UITableView!

Swift 2 errors with slider

Try this :

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")
cell.textLabel?.text = String(slider.value * Float(indexPath.row))
return cell


Trouble using tableView numberOfRowsInSection

Re-reading your question, I think this is your solution:

1.) Create an NSMutableArray for each date containing the games for that date.

2.) As you create each array, add it to a NSMutableDictionary with the key set as the Date for that array. [dictionaryVar setObject:yourArrayOfGames forKey:@"TheDateYouWantToUseForThatArray"];

3.) In your numberOfRowsInSection method, use the section Integer (that the method already has) to get the correct array. Since you can't access a property in a dictionary with an index integer, you'll need to convert the keys in the dict to an array and then use the section integer to grab the correct key, and then finally use it on the array. Should look something like:

NSMutableArray *arrayOfDictKeys = [[NSMutableArray alloc] init];

arrayOfDictKeys = [dictionaryVar allKeys]; //(this grabs a list of all the keys in the dictionary)
NSString *key = [arrayOfDictKeys objectAtIndex:section]; //(this is where you use the section var)

NSMutableArray *arrayForKey = [[NSMutableArray alloc] init];
arrayForKey = [dictionaryVar objectForKey:key];
return arrayForKey.count;

For this to work, you need to make sure the you insert the Key\Array pairs into your dictionary in the correct order, otherwise using section grab your key will probably grab you an unexpected date.

Ambiguous reference to member '(_:numberOfRowsInSection:)'

So, the problem is I didn't add an outlet of the table view to the View Controller.swift.
Just dragged the table view to the .swift file to create it.

Related Topics

Leave a reply