title: UITableView dataSource must return cell from tableView:cellForRowAtIndexPath
body: <p>I have a problem with my search bar I added in my <code>ViewController</code>. </p>
  
  <p>I am getting the following error:</p>
  
  <pre><code>Assertion failure in -[UISearchResultsTableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit/UIKit-2935.137/UITableView.m:6509
  2014-04-03 18:08:24.355 MyFood[6405:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
  </code></pre>
  
  <p><code>configureCell</code>:</p>
  
  <pre><code>- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {        
      //    ToDos *toDo = [self.fetchedResultsController objectAtIndexPath:indexPath];
      if (viewMode==AlphabeticalOrder) {
          Inventory *toDo=nil;
          if (self.searchDisplayController.isActive) {
              toDo = [searchResults objectAtIndex:indexPath.row];
          } else {
              toDo=[inventoryProducts objectAtIndex:indexPath.row];
          }
          cell.textLabel.text = toDo.inventoryProductName;
          NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
          [formatter setDateStyle:NSDateFormatterShortStyle];
          NSDate *dt = toDo.expireDate;
          NSString *dateAsString = [formatter stringFromDate:dt];
          cell.detailTextLabel.text = [NSString stringWithFormat:@"Until: %@", dateAsString];
      } else {
          Inventory *toDo=nil;
          if (self.searchDisplayController.isActive) {
              NSDictionary *sectionDict=[searchResults objectAtIndex:indexPath.section];
              NSArray *sectionData=[sectionDict objectForKey:@"SECTION_DATA"];
              toDo = [sectionData objectAtIndex:indexPath.row];
          } else {
              NSDictionary *sectionDict=[inventoryProducts objectAtIndex:indexPath.section];
              NSArray *sectionData=[sectionDict objectForKey:@"SECTION_DATA"];
              toDo=[sectionData objectAtIndex:indexPath.row];
          }
          cell.textLabel.text = toDo.inventoryProductName;
          NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
          [formatter setDateStyle:NSDateFormatterShortStyle];
          NSDate *dt = toDo.expireDate;
          NSString *dateAsString = [formatter stringFromDate:dt];
          cell.detailTextLabel.text = [NSString stringWithFormat:@"Until: %@", dateAsString];
      }
  }
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
      // Configure the cell.
      [self configureCell:cell atIndexPath:indexPath];
      return cell;
  
  }
  </code></pre>
  
  <p>code search bar:</p>
  
  <pre><code>   - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
      {
          if (searchText.length!=0) {
              if (viewMode==AlphabeticalOrder) {
                  NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"name contains[c] %@", searchText];
                  //            [searchResults removeAllObjects];
                  //            [searchResults addObjectsFromArray:[inventoryProducts filteredArrayUsingPredicate:resultPredicate]];
                  searchResults=[inventoryProducts filteredArrayUsingPredicate:resultPredicate];
              } else {
                  //-section mode
                  NSMutableArray *newDataArray=[NSMutableArray array];
                  for (NSMutableDictionary *aSectionDict in inventoryProducts) {
                      NSArray *sectionData=(NSArray*)[aSectionDict objectForKey:@"SECTION_DATA"];
                      NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"name contains[c] %@", searchText];
                      NSArray *filteredArray=[sectionData filteredArrayUsingPredicate:resultPredicate];
                      NSDictionary *sectionDataModified=[NSDictionary dictionaryWithObjectsAndKeys:filteredArray,@"SECTION_DATA",[aSectionDict objectForKey:@"SECTION_TITLE"],@"SECTION_TITLE", nil];
                      [newDataArray addObject:sectionDataModified];
                  }
                  searchResults=[NSArray arrayWithArray:newDataArray];
              }
          }
      }
  
      -(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
      {
          [self filterContentForSearchText:searchString
                                     scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
                                            objectAtIndex:[self.searchDisplayController.searchBar
                                                           selectedScopeButtonIndex]]];
  
          return YES;
      }
  </code></pre>
  
  <p>can anyone help?</p>