1

I have a UISearchbar with delegate method

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
if(searchText.length>3){
 [self updateSearchString:searchText];
}
}

updateSearchString goes out to the internet to get the results, formats them and updates the table view. I do not want this to occur if the user hits the backspace key. So I am thinking something like:

if(searchText.length>3 && lastCharacterTyped!=backspace){
  }

How do i determine the 2nd part?

Eric
  • 1,014
  • 2
  • 13
  • 22

1 Answers1

1

While I don't know of a particular way to detect backspace in Objective-C, the most reliable would be to check the length of the string before and after the lastCharacterTyped is typed. if the latter is less, means a backspace was pressed. Hope that helps.

Ayush Chaudhary
  • 716
  • 1
  • 8
  • 20