So I'm having trouble implementing a search bar in my app.
The methods find the filtered items but for some reason they won't show up in my tableview. I think it has something to do with adding the objects to the filteredListContentArray.
What object should I be adding for this to work.
Here's my code:
{
[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);}
That last NSLog reads (null) every time, but the NSLog Above it always shows the correct filtered items.