In the table view, I installed UISearchBar, installed the delegate, and added the protocol.
When a user clicks on a word, everything is in order, except that the search for “tennis” is different from “Tennis”.
How can I make the search bar case-sensitive UISearchBar? Here is my code where I think everything happens:
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
[tableData removeAllObjects];
if([searchText isEqualToString:@""]||searchText==nil){
[myTableView reloadData];
return;
}
NSInteger counter = 0;
for(NSString *name in dataSource)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
NSRange r = [name rangeOfString:searchText];
if(r.location != NSNotFound)
[tableData addObject:name];
counter++;
[pool release];
}
[myTableView reloadData];
}
source
share