views:

194

answers:

2

I've been following Apple's TableSearch code example, but it's not working for me and I think I'm doing everything the same way they did it. The method below should be fired whenever the user types anything into the search box, but it never gets fired for me, just on the sample app.

My header file has this implementation:

@interface ContactsTableVC : UITableViewController <UISearchDisplayDelegate, UISearchBarDelegate>{

I'm not sure what I'm missing or where else to look.

My NSLog never gets called.

Thanks for the help!

    - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString searchScope:(NSInteger)searchOption
{
    NSLog(@"The shouldreloadtableforsearchstring method has been called!");
    [self filterContentForSearchText:searchString];

    // Return YES to cause the search result table view to be reloaded.
    return YES;
}
A: 

Have you added the delegate UISearchDisplayDelegate in the @interface ContactsTableVC file.

Jordan
Ya, I have this: @interface ContactsTableVC : UITableViewController <UISearchDisplayDelegate, UISearchBarDelegate>{
Gorgando
A: 

Dang I feel dumb. I looked at everything at least 100 times to make sure I was going it right and as usually happens, it was something small that I overlooked. My TableViewController xib somehow had TWO SearchDisplayControllers in it in Interface Builder. It was defaulting to the first one, which was not linked to the search bar. I just had to delete that first SearchDisplayController and everything started working...

Thanks @Jordan for the quick response. Much appreciated!

Gorgando