lundi 26 juin 2017

if else statement using ".isEmpty" not working (swift3)

I have a textfield that stores a date using date picker. I have a textview that I would like to remain hidden until date is selected. To this i have the following code.

  override func viewDidLoad() {

    if let text = dptext.text, text.isEmpty {
        enterName.isHidden = true

    }}

This code hides enterName but when a date is selected enterName is still hidden. The code below is something else I tried but does not work.

 override func viewDidLoad() {

    if let text = dptext.text, text.isEmpty {
        enterName.isHidden = true

    } else {
     enterName.isHidden = false}}

All i am trying to do is when a date is entered in dptext, enterName becomes visible.

Aucun commentaire:

Enregistrer un commentaire