I am trying to not enable a button until both textfields are not nil. Thats it. I tried experimenting with viewdidappear but its not working. As soon as both textfields are not nil the button remains isenable = false.
import UIKit
class ViewController: UIViewController {
@IBOutlet var saveButton: UIButton!
@IBOutlet var textB: UITextField!
@IBOutlet var textA: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
safeGuard()
}
func safeGuard() {
if textA.text == "" || textB.text == ""{
saveButton.isEnabled = false
} else {
saveButton.isEnabled = true
}}}