In my tableViewController with a searchBar I am using the following method:
-(void) searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
...my code
}
and it works fine when I type text directly into the searchBar.
The problem I have now is that I want to invoke this method programatically - meaning that I want to fill in the search bar from my code which I know how to do (actually I am selecting a recently searched word in my language dictionary application) and call something like:
[SearchBar textDidChange: recentlySearchedWord]
but this simply does not work from anywhere in my code.
Please help me if you have some idea how to solve this.
Thanks,
Tim
If you implement UISearchBar's delegate method - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
in your view controller (or any class) and you want to call that method from within the same class, which is what you want to do I'm assuming, you'd have to call
[self searchBar:SearchBar textDidChange:recentlySearchedWord];
with SearchBar being the instance of the UISearchBar you are referencing.
textDidChange is not a class method. So instead of calling:
[SearchBar textDidChange: recentlySearchedWord];
call
[self searchBar:mySearchBar textDidChange: recentlySearchedWord];
Or if textDidChange is in a different class, use the class instance insted of self.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With