views:

70

answers:

1

I have a UISearchBar which is working fine, but I was wondering how I can set a scope and filter results based on certain criteria like: "Dogs and "Cats"

Tutorials and example code welcome.

A: 

Assuming you used the Interface Builder just add the scope button titles. They are indexed from 0.

Implement UISearchDisplayDelegate and UISearchBarDelegate. You will have to implement the method below (along with 2 others)

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption

Inside the method above use searchOption to get the scope index the user has selected. If your criteria has to be in string form then you should find a way to map the string to an integer value e.g use the NSDictionary or just manually compare if (0 == searchOption) ...

domino