title: Pushing UITableViewControllers and filtering/reloading the data
body: <p>I think this is probably a simple problem that I am not understanding but I have spent a lot of time on it and it is holding up my work.</p>
  
  <p>I have a UITableViewController that displays 4 rows of "topics". When you touch one, it creates an instance of my UITableViewController class, set's the data source array to the array of "subtopics" and pushes the controller onto the nav stack. When I go to my "All" topics page with say 10 rows, I have a segmented control for filtering the results. I am able to successfully filter the array but when I assign it to my self.topicsDataSource and call [self.tableView reloadData], nothing happens. The delegate methods numberOfSections and numberOfRowsInSection, but cellForRowAtIndexPath is not. When I press the navigation back button it goes back to and the previous table is now the filtered results I wanted in the top table.</p>
  
  <p>So here's what I think is happening. 
  1. I am actually altering the data source of the previous table, and self.tableView.reloadData is being called on that table. 
  2. cellForRowAtIndexPath is not called because the tableview being reloaded is not visible at that time.</p>
  
  <p>Here is where I am instantiating an pushing the table views. This class is called TopicsViewController</p>
  
  <pre><code>    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
  
      NSNumber *idtopic = [[self.topicsDataSource objectAtIndex:indexPath.row] idtopic];
      NSArray *subtopics = [DataManager getSubtopicsForTopic:idtopic];
  
      if ([subtopics count] &gt; 0) {
          TopicsViewController *topicsVC = [[TopicsViewController alloc ] init];
          topicsVC.tableView.rowHeight = 106;
          topicsVC.parentTopicId = idtopic;
          topicsVC.topicsDataSource = [NSMutableArray arrayWithArray:subtopics];
          topicsVC.diseaseStateId = self.diseaseStateId;
          topicsVC.title = [[self.topicsDataSource objectAtIndex:indexPath.row] topic];
          [self.navigationController pushViewController:topicsVC animated:YES];
      }
  
      else if (![[self.topicsDataSource objectAtIndex:indexPath.row] topic]) {
          //all topics was selected
          TopicsViewController *topicsVC = [[TopicsViewController alloc] initWithNibName:nil bundle:nil];
          topicsVC.tableView.rowHeight = 106;
          NSMutableArray *mArray = [[NSMutableArray alloc] initWithArray:[DataManager getTopicsAtEndOfTree]];
          topicsVC.allTopics = mArray;
          topicsVC.topicsDataSource = topicsVC.allTopics;
          topicsVC.diseaseStateId = self.diseaseStateId; 
          topicsVC.parentTopicId = [NSNumber numberWithInt:100];
  
          UISegmentedControl *segControl = [[UISegmentedControl alloc] initWithItems:[[NSArray alloc] initWithObjects:@"All", @"Speaker Direct", @"Live Meeting", nil]];
          [segControl addTarget:self action:@selector(segControlChanged:) forControlEvents:UIControlEventValueChanged];
          [segControl setSegmentedControlStyle:UISegmentedControlStyleBar];
          [segControl setSelectedSegmentIndex:0];
          topicsVC.navigationItem.titleView = segControl;
          topicsVC.tableView.dataSource = topicsVC;
          [self.navigationController pushViewController:topicsVC animated:YES];  
      }....
  </code></pre>
  
  <p>and here is where I am filtering the data and reloading the tableView: </p>
  
  <pre><code> - (void)segControlChanged:(UISegmentedControl *)sender
  {
      self.allTopics = [NSMutableArray arrayWithArray:[DataManager getTopicsAtEndOfTree]];
      if (sender.selectedSegmentIndex == 1) {
          NSPredicate *pred = [NSPredicate predicateWithFormat:@"type == 2"];
          NSMutableArray *mArr = [[NSMutableArray alloc] initWithArray:[self.allTopics filteredArrayUsingPredicate:pred]];
          self.topicsDataSource = mArr;
      }
      else if (sender.selectedSegmentIndex == 2) {
          NSPredicate *pred = [NSPredicate predicateWithFormat:@"type == 1"];
          NSMutableArray *mArr = [[NSMutableArray alloc] initWithArray:[self.allTopics filteredArrayUsingPredicate:pred]];
          self.topicsDataSource = mArr;
      }
      else {
          NSMutableArray *mArr = [[NSMutableArray alloc] initWithArray:[DataManager getTopicsAtEndOfTree]];
          self.topicsDataSource = mArr;
      }
      [self.tableView reloadData];
  
  }
  </code></pre>
  
  <p>Any help would be appreciated. Thanks!</p>