Note that there are some explanatory texts on larger screens.

plurals
  1. POContinuously updating UITableView issue
    primarykey
    data
    text
    <p>I have a searchbar in which the user searches for an address. Every time the inputed text is changed a selector is called, new addresses are searched and stored into an NSMutableArray. This works perfectly so far.</p> <p>Under the searchbar I have a UITableView which is called every time by </p> <pre><code>[searchTableView reloadData] </code></pre> <p>after a new address is added into the array.</p> <p>As soon as the first address is found, put into the array and the searchTableView is called the app crashes with following message:</p> <pre><code>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', </code></pre> <p>reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'</p> <p>Here is the code I am using:</p> <pre><code> - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { list = [[NSMutableArray alloc]init]; [geoCoder geocodeAddressString:self.addressSearch.text completionHandler:^(NSArray* placemarks, NSError* error){ for (CLPlacemark* aPlacemark in placemarks) { for (int i=0; i&lt;[placemarks count]; i++) { NSString *temp = [NSString stringWithFormat:@"%@",[[[[placemarks objectAtIndex:i]addressDictionary] valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "]]; [list addObject:temp]; [searchTableView reloadData]; NSLog(@"List: %@", list); } } }]; } - (UITableViewCell *)tableView:(UITableView *)tableVieww cellForRowAtIndexPath:(NSIndexPath *)indexPath { ... if (tableVieww == savedTableView) { UIView *bgColor; cell = [self.savedTableView dequeueReusableCellWithIdentifier:[list objectAtIndex:indexPath.row]]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[list objectAtIndex:indexPath.row]]; cell.accessoryType = UITableViewCellAccessoryNone; bgColor = [[UIView alloc] initWithFrame:cell.frame]; [cell addSubview:bgColor]; [cell sendSubviewToBack:bgColor]; } cell.textLabel.text = [list objectAtIndex:indexPath.row]; cell.textLabel.backgroundColor = [UIColor clearColor]; cell.textLabel.textColor = [UIColor whiteColor]; if (indexPath.row % 2 == 0){ bgColor.backgroundColor = [UIColor colorWithRed:098.0f/255.0f green:211.0f/255.0f blue:182.0f/255.0f alpha:0.90f]; } else { bgColor.backgroundColor = [UIColor colorWithRed:230.0f/255.0f green:089.0f/255.0f blue:128.0f/255.0f alpha:0.90f]; } } return cell; } </code></pre> <p>Thanks for the help!</p> <p>Cheers</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload