I am making a demo Weather app, and inside this i am using UISearchBar so can user entry city name, but i don't know how to display suggestion for that.
For example, if user enters "lon" than there should be cities name suggesting start from "lon" like London, etc.
UISearchBar
has its own delegation protocol UISearchBarDelegate
, the method -
-(BOOL)searchBar:(UISearchBar *)searchBar
shouldChangeTextInRange:(NSRange)range
replacementText:(NSString *)text
make possible while editing to do some extra operations, here you can put your NSPredicate
to see if the inserted text has a city that BEGINSWITH
or CONTAINS
the entered text.