Tableview:Numberofrowsinsection:]: Unrecognized Selector Sent to Instance

tableView:numberOfRowsInSection:]: unrecognized selector sent to instance

Read what the error message is telling you!

You have implemented numberOfRowsInSection:. So what? That's the wrong method. It is irrelevant. It will never be called.

The method you need to implement is called tableView:numberOfRowsInSection:. That's completely different.

-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance

please ensure you deleted outlets from code but not from storyboard.just right click on tableview from storyboard .delete outlets and reconnect it.May be you have added two outlets for same tableview.

UITableView unrecognized selector sent to instance

Have you set Tableview delegate to UITableViewDataSource using storyboard or programmtically.?

set Tableview delegate to UITableViewDataSource programmtically.

yourtableview.dataSource=self

or

using storyboard set Tableview delegate to UITableViewDataSource show below image.

Sample Image

Or

check if you set UITableViewDataSource wrong to any other view.

-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7ff437517770

This is happened because you have set DataSource from Storyboard. but I think you have forgot to set Home as Class in Storyboard

Sample Image

UITableView unrecognized NumberOfRowsInSection

Don't guess the correct signature for the method. There are two ways to get it right.

  1. The best option is to let Xcode give you the correct signature. Start typing the name (such as "numberOfRows") and Xcode will show possible matching methods. Select the correct one.
  2. The other option is to copy the correct signature from the reference documentation.

Here is the correct method signature:

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int

You are missing the underscore.

And why do you have two attempts at the numberOfSections method? Just use the correct one:

func numberOfSections(in tableView: UITableView) -> Int

Most likely you copied and pasted examples from some Swift 2 code. The APIs changes a lot in Swift 3.

Unrelated to your issue (as mentioned in the comments), do not call listCitta() from any of your table view data source or delegate methods. You should call that once (such as in viewDidLoad) and use a property to hold onto the array of results. Then your data source and delegate methods should simply access that property.

Swift UITableView unrecognized selector sent to instance

Resolved: I moved chatsTable.dataSource = self to before the if statement, and this resolved the problem. Most likely it couldn't find the numberOfRowsInSection method because the dataSource was only set if there was a currentUser.

[tableView:numberOfRowsInSection:]: unrecognized selector sent to instance

The problem you getting is in this line:

self.rootTable.dataSource = self.categoriesArray;

you set up table data source to the array. I believe you want to set it up to self:

self.rootTable.dataSource = self;

Just remember to implement the data source methods in your view controller.

Xcode TableView - unrecognized selector sent to instance

That error message is displaying because tableView:numberOfRowsInSection: is being sent to an object of type UINavigationItem while it seems like your CraftingViewController class is probably of type UITableViewController. I would make sure that you have connected your delegate to the correct class, because it doesn't seem like CraftingViewController is connected properly.

UITableView crash Unrecognized selector sent to instance

The error message says you are sending the method tableView:numberOfRowsInSection: to a UIView object, which does not understand that method. Either your tableview's data source is incorrect, or you meant to send a different method to the UIView.

If you cannot find the line of code with your bug, you might share more code. Otherwise, the code you have posted is just boilerplate and is unhelpful. But that is what your error message means.



Related Topics



Leave a reply



Submit