Take the 2-minute tour ×

Im wondering if someone can please tell me what am I missing. I got a tableview with two sections, but when I tap onto anything on section 2, content from section 1 cells is loaded. Thanks in advance.

here is my didselectrowatindexpath:

   [[self navigationController] pushViewController:targetViewController animated:YES];

if (indexPath.section == 0)
      [partA  objectAtIndex:indexPath.row];
      [partB objectAtIndex:indexPath.row];

      [targetViewController release];
share|improve this question
btw You're releasing an object [targetViewController release] you didn't create or retain. objectForKey returns autoreleased object from NSDictionary... –  chilitechno.com Apr 30 '11 at 20:09

3 Answers 3

In your tableView:didSelectRowAtIndexPath: method, you may not be accounting for the section; i.e. you're pulling a UIViewController from the views array using indexPath.row, when you should probably also be using indexPath.section as a qualifier. It's hard to give a better answer without seeing more of your view controller.

share|improve this answer
Thank you for your suggestion. I'll change indexPath.row for indexPath.section to see results and post my results. –  Rey 777 May 3 '11 at 20:58

You may consider to use following code instead of your if statement.

UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:indexPath];

Also remove the release because you did not retain or allocate it.

But honest: I do not understand what you want to do. What do you mean by "loaded"? Loaded where?

share|improve this answer
Sorry I didnt make myself clear, by "loaded" I meant pushing an accesory view for each component "partA section & partB section"; so when I sectioned the table view, section two (partB objectAtIndex...) loads the content for partA. –  Rey 777 May 3 '11 at 20:56

You haven't provided it but my guess is that you should override didSelectRowAtIndexPath method and check the owner of the selecting cell:



if ( tableView == _tableView1){

     //Do something

else if ( tableView == _tableView2){

     //Do something different

else return;
share|improve this answer

Your Answer


