Search code examples
iphoneobjective-ccocoa-touchuisearchbaruisearchdisplaycontroller

UISearchDisplayController is not displaying any cells


I have a UISearchDisplayController that is properly hooked up in Interface Builder.

delegate = Files Owner
searchBar = Search Bar
searchContentsController = Files Owner
searchResultsDataSource = Files Owner
searchResultsDelegate = Files Owner

When my UITableView calls numberoOfRowsInSection: the correct number is returned.

However, my cells in cellForRowAtIndexPath: don't even reach:

- (UITableViewCell *)tableView:(UITableView *)tblView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

 if (tblView == searchController.searchResultsTableView){
  NSLog(@"search will go here");
  UITableViewCell* cell = [self provideSearchQueryCells:tblView identifer:@"searchQueryCell"];
  STSymbol *aSymbol = [self.searchQueryResults objectAtIndex:indexPath.row];

  cell.textLabel.text = aSymbol.symbol;
  cell.detailTextLabel.text = aSymbol.symbol_title;

  return cell;
 }
 else { ... }

It always goes to the else condition.

I am not exactly sure why.


Solution

  • I needed to create an instance of a UISearchDisplayController instead of using self.searchDisplayController.