[:en]To check whether or not the textfields are empty or cotains “,” symbol:
// Check for empty fields // // 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") { print("Swift") } else if string!.contains(",") { print (",") } else { print ("Ready") } } }
[:]