I have UIBarButtonItem and whenever I try to set title to the button, its not working.
@IBOutlet weak var barButton: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
barButton.title = "AB"
}
But if I try to create Action of UIBarButtonItem and then do sender.setTitle() then it works. But not at viewDidLoad. I don't want to set title when user taps on the button.

Try this instead