0

I have a tableview in my viewcontroller. But i have an error which say that [tableview:numberofrowinsection:]:unrecongized selector sent to instance. Can someone please tell me how cna i solve this.

2 Answers 2

1

You need to set the UIViewController as the delegate, and also datasource also you need to implement the necessary methods. if you look in the apple docs they are described there but i think the main ones are:

  • numberOfSectionsInTableView:
  • tableView:numberOfRows:inSection:
  • and tableView:cellForRowAtIndexPath:

in the first one you return the number of sections, usually 1, in the second you return the number of rows for the section( usually the count of the array) and in the final you return the UITableViewCell object with the necessary data put in position.

read the apple docs, and if necessary copy the method names from one of the UITableViewController templates.

hope this helps

Sign up to request clarification or add additional context in comments.

Comments

0

Create a new file using the UITableViewController template - it has skeleton code that should help (even if you don't use it to build on, you can use it as an example of implementing the delegate methods and reusing cells).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.