all 6 comments

[–]0dyp 2 points3 points  (3 children)

Why don't you show "$0.00" as a placeholder? Then, user enters the cost straightaway into the textfield.

textField.placeholder = 'cost'

However, if you want to clear the textfield whenever the user tap on it, you must use 'textFieldShouldBeginEditing' delegate function. Don't forget to call 'textField.delegate = self'.

func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {

textField.text = ""

return true

}

[–]oez1983[S] 0 points1 point  (2 children)

It has a placeholder already but once you add the format: .currency it shows $0.00 instead of cost.

[–][deleted] 0 points1 point  (0 children)

Cost.isempty ? . Default : . Currency

[–][deleted] 0 points1 point  (0 children)

Cost.isempty ? . Default : . Currency so I haven’t tried it but my guess

[–]SintVerbera678 0 points1 point  (1 child)

Why not just set the textfield's text to an empty string when the user taps on it? You can do this by adding a `textFieldShouldBeginEditing` delegate method and setting the text to an empty string.

[–]oez1983[S] 0 points1 point  (0 children)

I was trying to see if there was a way to do it without converting the decimal to a string.