سؤال

I want to be able to get the text the user entered into a search bar, and compare the words in an array. But i'm not sure how to get the text from the search bar, I know in java its just getText.

هل كانت مفيدة؟

المحلول

Assuming you named the UISearchBar just searchBar, you can retrieve the text with

searchBar.text

نصائح أخرى

In SearchBar Delegate method, you can get searchbar text

-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    NSString *str = searchBar.text;
    NSLog(@"%@",str);
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top