does anyone know how to test when the last character in a UISearchBar is deleted. i.e. you type …
Gary > return "Gary"
Gar > return "Gar"
Ga > return "Ga"
G > return "G"
> return ???
.
-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
[self FG_Filter:searchText];
}
I was thinking it would be @”” but I am having trouble getting that to work.
many thanks
Gary
Actually, it returns
nil. (Or at least it did when I wrote mysearchBar:textDidChange:.)But writing code that assumes that is probably foolish. Apple could change it to return
@""next release. Instead, you’re better off checking for what you actually care about: Is the field empty?If you’d prefer not to change FG_Filter, something like this would be a safe change, too: