2
나는 tableview + 검색 창으로보기를 만들었습니다. 문자열의 첫 단어를 검색하면 완벽하게 작동합니다! 불행히도 문자열에서 다른 단어를 검색하면 작동하지 않습니다. 그래서 텍스트 검색을한다면 : bal.UISearchBar의 두 번째 단어 검색
그리고 다음 문자열을 살펴보아야합니다. 녹색 발. 아무것도 찾지 못할거야.
나는 현재이 코드를 사용하여 데이터를 검색 창에 텍스트를 비교하고있다 :
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
[self.filteredListContent removeAllObjects]; // First clear the filtered array.
for (Product *product in self.listContent)
{
NSComparisonResult result = [product.name compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])];
if (result == NSOrderedSame)
{
[self.filteredListContent product];
}
}
NSMutableSet *tempSet = [NSMutableSet setWithArray:self.filteredListContent];
self.filteredListContent = [NSMutableArray arrayWithArray:[tempSet allObjects]];
}
가 어떻게이 문제를 해결할 수
?도움이나 의견을 보내 주시면 감사하겠습니다.
이 방법은 잘 작동합니다. 감사! – justinkoh