검색 막대가있는 tableview가 있습니다. NSPredicate to Search Collection
for(head in items){
[desc addObject:head.DESC];
[category addObject:head.CATEGORY];
}
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"self CONTAINS[cd] %@", searchText];
searchResults = [desc filteredArrayUsingPredicate:resultPredicate];
}
지금 내가있는 tableView didSelectRowAtIndexPath이 카테고리의 객체를 사용할 수 있도록 함께 컬렉션을 유지하려면 : 나는 다른 배열에 항목을 추가 할 때 내가있는 tableview를 검색 할 자 NSPredicate를 사용 할 수 있었다.
나는 이런 식으로 내 테이블보기를로드
for (int i = 0; i < [items count]; i++){
head = [items objectAtIndex:indexPath.row];
labelName.text = head.DESC;
는 어떻게 자 NSPredicate는 head.DESC에 대한 컬렉션을 검색 할 수 있습니까?
#pragma mark Search Results
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"self CONTAINS[cd] %@", searchText];
searchResults = [items filteredArrayUsingPredicate:resultPredicate];
}
현재 위의 코드를 실행할 때 예외가 발생합니다.
reason: 'Can't use in/contains operator with collection <Order: 0x7b22e900> (not a collection)'
용서, 나는 블록의 큰 이해가되지 않습니다. 이 컨트롤은 void가 아닌 블록의 끝에 도달합니다. 무엇을 반환해야합니까? – iDev
하! 와! 해당 줄의 시작 부분에 반품이 있어야합니다. 그건 내 잘못이야. –
그래, 충돌하지 않습니다. 검색 결과가 비어 있습니다. 아웃 블록이있는 방법이 있습니까? – iDev