I have simple view controller that is embedded in navigation controller, also I create by drag a’drop an bar button item to the right, connected it as action to the code and named it edit. So what I want it, if click on the button it should verify the title and change it if needed, here is the code:
class MyClass: ViewController {
@IBAction func editButtonPressed(sender: AnyObject) {
if (self.navigationItem.rightBarButtonItem?.title == "Edit") {
self.navigationItem.rightBarButtonItem?.title == "Done"
} else {
self.navigationItem.rightBarButtonItem?.title = "Edit"
}
but its doesn’t work. Thank ever for the advances