I am getting the following error on a very simple UITableView:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x5d73210'
Here is my code:
#pragma mark -
#pragma mark Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return 10;
}
You have to return at least 1 section… I’ve tested this in a newly created UIViewController XIB called testes (add new .h and .c files and check the box to created XIB with it and also to make it a UITableViewController subclass) and it works fine.
How did you create the tableview? Did you create it’s own XIB like I wrote above or did you just throw a tableview into the MainWindow.xib file? Try creating you own and you should be good. Just make sure in AppDelegate to set the main view that gets added on
didFinishLaunchingWithOptionsto the new tableview you create. In IB, the UIViewController for the tableview should be set to testes subclass (which is a UITableViewController subclass)App Delegate files
and
And then in the viewcontroller .m file