Joe Sloan Joe Sloan - 1 year ago 58
Swift Question

Using UITextfField, how can I set the placeholder text programmatically in swift?

I'm pulling a phone number from a database, and when the user begins editing in the text field to change that phone number I'd like to use the number I currently have in the database as the placeholder. Since this information changes with each user, how can I set it programmatically in swift?

Answer Source

You need to get the phone number from your database first (convert them to String), then you set placeholder of your textField to that String, like so

 textField.placeholder = phoneNumberString
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download