Xcode iphone sdk - Searching in UITableView, different pattern matching
- by Lorenzo
Hi everyone,
I'm coding a UITableView with a UISearchBar to search between a list of cities (loaded in the uitableview)
Here is my code for searhing:
- (void) searchTableView {
NSString *searchText = searchBar.text;
NSMutableArray *searchArray = [[NSMutableArray alloc] init];
for (NSDictionary *dictionary in listOfItems)
{
NSArray *array = [dictionary objectForKey:@"Cities"];
[searchArray addObjectsFromArray:array];
}
for (NSString *sTemp in searchArray)
{
NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch];
if (titleResultsRange.length > 0)
[copyListOfItems addObject:sTemp];
}
[searchArray release];
searchArray = nil;}
And with this everything works fine, but i need to do something a bit different.
I need to search only between items that match pattern Word* and not * Word *.
For example if I search "roma", this need to match just with "Roma" or "Romania" and not with "Castelli di Roma".
Is that possible with this searchbar? How can i modify this?
Thanks