How do you get the text the user entered into the search Bar?

gikygik picture gikygik · Jun 15, 2011 · Viewed 8.4k times · Source

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.

Answer

PengOne picture PengOne · Jun 15, 2011

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

searchBar.text