UIButton title doesn't work
В сториборде создал 2 кнопки. Назначил им title (через все тот же storyboard). Привязал @IBAction к каждой кнопке, но почему-то пишет, что title - nil. Если же задавать программно title, то после клика по кнопке не возникает ошибки. Как это можно исправить?
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func firstBtnTap(_ sender: UIButton) {
sender.setTitle("Tapped", for: .normal)
print(sender.title(for: .normal)!)
}
@IBAction func secondBtnTap(_ sender: UIButton) {
print(sender.title(for: .normal)!)
}
}