これは私のコードです:
-(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"];
}
}
問題は、ユーザーが完全な検索用語を入力する前に完全一致検索が開始されることです (正確がチェックされている場合)。これを防ぐにはどうすればよいですか?