HI, I successfully perform a search within arrayTags with the following code, where arrayTags is the array of a field of each XML element, named "tag". The problem is that, let's say, tag has three words: red, white, blue. If I perform a search "red" or "white, blue", or whatever exactly included in a tag element, everything is OK. But if I search "red white", the search returns nothing. Practically, the search returns results only if I search exactly what is included in the arrayTags, but not non-consecutive words. Do you know how can I solve this problem? Thanks so much!
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
[resultArray removeAllObjects];
NSString *cellTitle;
for (cellTitle in arrayTags){
NSString *stringa = cellTitle;
NSRange range = [stringa rangeOfString:searchText];
NSComparisonResult result = [cellTitle compare:searchText options:NSCaseInsensitiveSearch range:range];
if (result == NSOrderedSame){
int posizione = [arrayNames indexOfObjectIdenticalTo:cellTitle];
[result Array addObject:[arrayNames objectAtIndex:posizione]];
}
}
[self.tableView reloadData];
}