오랫동안 검색하고, 주저하고 더 많은 검색을 한 후에 나는 이것을 알아낼 수 없습니다.SearchDisplayController 여러 배열로 검색
저는 SearchDisplayController가 있습니다. 각 UITableViewCell이 4 개의 문자열 (제목, 설명 등)으로 이루어지기 때문에 NSPredicate를 사용하여 검색 할 곳이 4 개의 다른 배열을 가지고 있습니다.
내가 지금 가지고있는 다음과 같은 가득 4 검색 배열, search_title, SEARCH_DESCRIPTION 등 :
- (void)filterContentForSearchText:(NSString*)searchText
scope:(NSString*)scope
{
NSPredicate *resultPredicate = [NSPredicate
predicateWithFormat:@"SELF contains[cd] %@",
searchText];
self.search_category = [self.temp_category filteredArrayUsingPredicate:resultPredicate];
self.search_producttitle = [self.price_producttitle filteredArrayUsingPredicate:resultPredicate];
self.search_type = [self.price_type filteredArrayUsingPredicate:resultPredicate];
self.search_description = [self.price_description filteredArrayUsingPredicate:resultPredicate];
내가 NSLog (배열 회수)를 사용하는 경우, 나는 그것이 정확한 수를 제공하기 때문에이 작동하고 볼 수 있습니다 검색어를 입력 할 때마다 각 배열을 찾습니다.
내있는 tableview 셀은 다음과 같습니다
if ([tableView isEqual:self.searchDisplayController.searchResultsTableView]){
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.nameLabel.text = [self.search_producttitle objectAtIndex:[[searchResults objectAtIndex:indexPath.row] integerValue]];
cell.priceLabel.text = [self.search_price objectAtIndex:[[searchResults objectAtIndex:indexPath.row] integerValue]];
cell.descrLabel.text = [self.search_description objectAtIndex:[[searchResults objectAtIndex:indexPath.row] integerValue]];
cell.IDLabel.text = [self.search_type objectAtIndex:[[searchResults objectAtIndex:indexPath.row] integerValue]];
}
else{
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.nameLabel.text = [price_producttitle objectAtIndex:indexPath.row];
cell.IDLabel.text = [price_type objectAtIndex:indexPath.row];
cell.priceLabel.text = [price objectAtIndex:indexPath.row];
cell.descrLabel.text = [price_description objectAtIndex:indexPath.row];
어쩌면 당신은 이미 내가 할 노력하고있어 볼 수 있습니다. 이제 검색 배열이라고 부르는 기존 배열에서 새 배열을 만들고 있습니다. 그러나 이러한 배열은 서로 독립적입니다 (한 배열은 비어있는 반면 다른 배열은 연구 결과로 채워질 수 있음). 나는 그 색인이 어디 있는지 알 필요가있다. 그것은 그 searcharrays에 저장되어있다. search_producttitle의 데이터가 price_producttitle (원래 배열)의 인덱스 1,3 및 4에서 나온다는 것을 알고 있다면 indexPath.row에 해당 숫자를 사용하여 표시 할 수 있습니다. 적어도 지금은 내 계획이며 셀을 만들 때 objectAtIndex에 사용해야하는 숫자가 들어있는 searchResult 배열을 만드는 것입니다.
저는이 작업에 어려움을 겪고 있습니다. 셀이 여러 배열로 구성되어 있기 때문에 여러 배열 내에서 검색하는 예제를 찾을 수 없습니다.
누군가 좋은 방향으로 나에게 유용한 힌트를 제공 할 수 있습니까?
미리 감사드립니다.
Prastow
참조 내가 사용 : 아무도 내 질문에 대답하지 않지만
SearchDisplayController search multiple arrays