This is an extension, not a duplicate, of How to check if a text field is empty or not in swift
The given answer,
@IBAction func Button(sender: AnyObject) {
if textField1.text != "" {
// textfield 1
}
}
does not work for me, i.e., the if-loop is triggered even when nothing is entered in the text field. (I have modified it from the original because I'm looking to trigger the code only when the field contains text).
The second answer
@IBAction func Button(sender: AnyObject) {
if !textField1.text.isEmpty{
}
}
comes much closer, but it accepts strings like " "
as not empty. I could build something myself, but is there a function that will check if a string contains something other than whitespace?