I have this part of a method that is giving me an error.
This is a word filter, user types a, all words come up, etc…
Error comes when user deletes the searchbar text, and clicks something on the table, I get out of bounds exception.
The print out for filteredListContent is a single “” entry, what should I implement from keeping the “” from crashing the program?
Thanks
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([_filteredListContent count]>0){
NSLog(@"%i",indexPath.row);
NSLog(@"%@",_filteredListContent);
_searchBar.text=[self.filteredListContent objectAtIndex:indexPath.row];
//Save to user default
I’m not sure what is causing your problem but from the code given it looks like the row selected is “out of bounds”. I would change my check:
to something like:
Again this is just based on the code given.