Joe Sloan Joe Sloan - 11 months ago 34
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?


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