iOS中searchBar的模糊搜

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText

{

[requestView searchFromTalbeView:searchText];

}

- (void)searchFromTalbeView:(NSString *)text

{

NSString *searchText=text;

if (searchText.length>0) {

_searching=YES;

[copyArray removeAllObjects];

for (NSString *tempStr in sourceArray) {

NSRange titleResult=[tempStr rangeOfString:searchText options:NSCaseInsensitiveSearch];

if (titleResult.length>0) {

[copyArray addObject:tempStr];

}

}

}

}

你可能感兴趣的:(iOS中searchBar的模糊搜)