Navigation item does not change the title

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

Did you connect the rightbarbuttonitem you dragged to the declaration of it in code?

Hallo marciokoko,
I found already my error, in the third line, I used equals operator rather then assign operator,
with this line it works neat:

if (self.navigationItem.rightBarButtonItem?.title == "Edit") {
   self.navigationItem.rightBarButtonItem?.title = "Done"
} ...