0
그래서 내 앱에서 검색 창을 구현하는 데 문제가 있습니다.UISearchBar 메서드로 도움말
메서드는 필터링 된 항목을 찾지 만 어떤 이유로 내 tableview에 표시되지 않습니다. 나는 filteredListContentArray에 객체를 추가하는 것과 관련이 있다고 생각한다.
이 기능을 사용하려면 어떤 개체를 추가해야합니까?
마지막 NSLog는 (널)마다,하지만 위의 NSLog를 읽{
[self.filteredListContent removeAllObjects]; // First clear the filtered array.
for (NSDictionary *dictionary in tableDataSource)
{
NSString *testString = [dictionary valueForKey:@"Title"];
NSLog(@"String list to be Searched is %@", testString);
//NSLog(@"Contents of list are %@", testString);
NSComparisonResult result = [testString compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])];
//NSObject *filteredObject = [dictionary objectForKey:@"Title"];
if (result == NSOrderedSame)
{
NSLog(@":-)");
NSLog(@"Resulted object is %@", [dictionary valueForKey:@"Title"]);
[self.filteredListContent addObject:dictionary];
}
else
{
NSLog(@":-(");
}
}
NSLog(@"Contents of Filtered list are %@", self.filteredListContent);}
항상 정확한 필터링 항목을 보여줍니다
여기 내 코드입니다.
와우. 샘플에서 한 줄의 코드가 누락되었습니다. self.filteredListContent = [NSMutableArray arrayWithCapacity : [self.tableDataSource count]]; 정말 고마워! – monotreme