swift - Select all text in a UITextField -


how programatically select text in swift text field?

like safari

enter image description here

i try this:

textfield.becomefirstresponder()  textfield.selectedtextrange = textfield.textrange(from: textfield.beginningofdocument, to: textfield.endofdocument) 

or this:

textfield.selectall(self) 

but not effect want.

if aim select text in uitextfield, use this:

textfield.selectall(nil) 

Comments