I have added a search bar with UITableView. when I enter the first character then it search all records starting with that character but when i enter the next character then it search nothing.
Kindly help me. If this is a silly question then kindly be patient and guide me
Thanx
Code
-(void)searchData:(NSString*)search{
// search = [search uppercaseString];
NSLog(@"Array count233 : %d", [menuArray count]);
NSLog(@"Array count237 : %d", [menuArray count]);
NSLog(@"Search String : %@", search);
if ([search isEqualToString:@""]) {
}
else {
[tableMenuArray removeAllObjects];
for (int i = 0; i < [menuArray count]; i++) {
if ([[[menuArray objectAtIndex:i] itemName] hasPrefix:search]) {
[tableMenuArray addObject:[menuArray objectAtIndex:i]];
NSLog(@"Found");
}
}
}
[menuTableView reloadData];
}
If you uncomment the 2nd line, then change this line –
…to –
Otherwise you’re comparing all-uppercase to normally-cased words. Hope this sorts it for you!