title: trying to get a 'Search Bar and Display Controller' to repopulate a table view
body: <p>I am trying to get the 'Search Bar and Display Controller' functionality to work in an iOS app. I am able to NSLog in repsonse to a search query and hardcode in a new array but am unable to get the table view to repopulate. I have the following for in response to a user submit on the search button:</p>
  
  <pre><code>- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
    NSLog(@"You clicked the search bar");
    NSMutableArray *filteredResults=[[NSMutableArray alloc] init];
  
    Person *filteredPerson=[[Person alloc] init];
    filteredPerson.firstName=@"Josie - here i am";
    [filteredResults addObject:filteredPerson];
    _objects=filteredResults;
    self.tableView.dataSource = _objects;
    [self.tableView reloadData];
  }
  </code></pre>
  
  <p>Any ideas on making this repopulate would be appreciated.</p>
  
  <p>thx</p>
  
  <p><strong>edit #1</strong>
  It looks like this is populating the _objects NSMutableArray:</p>
  
  <pre><code>- (void)insertNewObject:(id)sender
  {
      if (!_objects) {
          _objects = [[NSMutableArray alloc] init];
      }
      [_objects insertObject:[NSDate date] atIndex:0];
      NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
      [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
  }
  </code></pre>
  
  <p>Should I just create a new _objects and use insertNewObject rather than the addObject code I have above? Would this bypass the need to deal with the dataSource property of the table view?</p>
  
  <p><strong>edit 2</strong>
  per @ian</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"Cell";
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
          cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
      }
  
      /*
      NSDate *object = [_objects objectAtIndex:indexPath.row];
      cell.textLabel.text = [object description];
      */
  
      Person *rowPerson = [_objects objectAtIndex:indexPath.row];
      cell.textLabel.text = [rowPerson firstName];
  
      return cell;
  }
  </code></pre>
  
  <p>thx</p>