UISearchBar: text property
The text property is the text in the search bar.
Value
A string.
- Readable and writable.
- The default is the empty string
'', notnull. - Writing
nullorundefinedgives''; writing a number gives its string form. - It is the same text as
textonsearchTextField. - When the user changes the text (typing, deleting, tapping the clear button), the search bar fires
input. Writingtextin code doesn't fire it, so changingtextin aninputcallback doesn't cause a loop.
Examples
js
const search = new UISearchBar();
search.text = 'beijing';
console.log(search.text);Effect: beijing appears in the text field, and the console prints beijing. input doesn't fire.
Corresponding iOS API
UISearchBar.text. nil reads as ''.
See also
inputeventplaceholder