0

This is my code:

-(void)searchBar:(UISearchBar*)va textDidChange:(NSString*)text  {

NSPredicate *predicate;

//  what are we searching for?
if(doExactSearch == NO) {
    if( [oSearchByISBN isSelected])
        predicate = [NSPredicate predicateWithFormat:@"isbn contains [c] %@", text];
    else if( [oSearchBySKU isSelected])
        predicate = [NSPredicate predicateWithFormat:@"sku contains [c] %@", text];
    else if( [oSearchByTitle isSelected])
        predicate = [NSPredicate predicateWithFormat:@"title contains [c] %@", text];
    else if( [oSearchByAuthor isSelected])
        predicate = [NSPredicate predicateWithFormat:@"author contains [c] %@", text];
    else  {
        CommonMethods *cm  = [[CommonMethods alloc] init];
        [cm showAlertView:@"Error" message:@"You must choose the field to search on"];
    }
}
else if(doExactSearch == YES)  {
    if( [oSearchByISBN isSelected])
        predicate = [NSPredicate predicateWithFormat:@"isbn == %@", text];
    else if( [oSearchBySKU isSelected])
        predicate = [NSPredicate predicateWithFormat:@"sku == %@", text];
    else if( [oSearchByTitle isSelected])
        predicate = [NSPredicate predicateWithFormat:@"title == %@", text];
    else if( [oSearchByAuthor isSelected])
        predicate = [NSPredicate predicateWithFormat:@"author == %@", text];
    else  {
        CommonMethods *cm  = [[CommonMethods alloc] init];
        [cm showAlertView:@"Error" message:@"You must choose the field to search on"];
    }
}

The problem is that the exact search starts before the user has entered the complete search term (if exact is checked). How do I prevent this?

SpokaneDude
  • 4,856
  • 13
  • 64
  • 120

0 Answers0