0

I got the following error and I can't seem to figure out what happened. Please help me.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x57405a0'

4
  • you are calling a UITableViewControllerDelegate method (numberOfRowsInSection:) on a UIViewController which doesn't implement the protocol. That's about all we can tell you from what you've provided. We need to see how you populate your UITabBarController. Commented Jun 6, 2011 at 20:25
  • What do you want me to show? Sorry, I'm new to Objective-C. Commented Jun 6, 2011 at 20:27
  • What are you returning from numberOfRowsInSection method ? Commented Jun 6, 2011 at 20:36
  • - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [array count]; } Commented Jun 6, 2011 at 20:36

3 Answers 3

1

If you're using:

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [array count]; } –

Try:

NSLog(@"%i", [array count]);

And see what returns. Maybe the array is not been properly allocated.

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

Comments

0

This could be anything. It might be a delegate being called which does not implement the protocol, or it might be a memory leak where a call is made on some released memory. Hard to tell like this. Try compiling with "Analyze" and check all warnings.

1 Comment

I don't have any leaks when I run with "Analyze".
0

I had a similar problem, but the solution was not associated with the numberOfRowsInSection: method as Xcode was pointing too.

Instead, the overriding problem was that I had not set my UIViewController's Custom Class setting... In my case it was empty instead of having a valid class name like "DetailsVC2" in the example image below. Once I corrected this issue the usual numberOfRowsInSection: operation is recognized and called correctly.

Typically, you want to return the count of an array (e.g. tableData), but in my very simple case I returned the value of 1.

NSArray *tableData; // Defined somewhere above, and populated prior to the viewDidAppear() operation

 .
 .
 .

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
  return 1; // or tableData.count;
}

enter image description here

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.