[:en]How to make a simple empty text field checker.
// // ViewController.swift // CheckEmptyField // // Created by Cambridge on 11/4/2019. // Copyright © 2019 Cambridge . All rights reserved. // import UIKit class ViewController: UIViewController { @IBOutlet weak var textfield: UITextField! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } // To check the textField contains @IBAction func pressAction(_ sender: Any) { let string = textfield.text if string!.isEmpty { print("empty") } else if string!.contains("Swift") { // case sensitive print("Swift") } else if string!.contains(",") { print (",") } else { print ("Ready") } } }
[:]