UIBarButtonItem action does nothing


I’m a little worried this is too stupid a question to ask here, but here goes. I have a tableViewController with static cells to take some setting information. I’ve added a bar button called “Done” and hooked it up to my controller. I am attempting to just update the settings for a particular user. But it does nothing. I’ve tried just a basic print() in here and still nothing. So I’m really lost as to why it doesn’t work. I’ve attached a screen shot too

There are no stupid questions just stupid storyboards… or something like that.

Anyway, unwind segue is confusing and a little more complicated than it needs to be in my opinion. You can use the special “Exit” item at the top of the view controller, and you have to link it up as this incredibly popular Stack Overflow answer describes.

But what I usually do is link the control that I want to do the exit with to a plain IBAction in my view controller - and at the end of whatever actions I want to do I use dismissViewController: or popViewController: (depending on whether or not I am in a nav controller).

Yes it is slightly more code, but what it does is obvious and simple.

1 Like

Ok, I will look into this, again thank you.

I am taking from the read of you answer that I should remove the unwind segue and just call a IBAction that updates my Data Model and then finishes with the dismissViewController or popViewController which would effectively return me back to my Navigation controller?

hi Jonny ,

popViewController will effectively return me back to your Navigation controller . More Over there may be a constants issue or Autolayouts issue . just check it once in story board . Even just try my having a executable break point .

Thanks for your help, in the end I went for

// return back to nav controller
    self.dismissViewControllerAnimated(true, completion: nil)

And it seemed to work fine. I am not sure what or if there should any kind of error checking here though. Can this method fail at all and I need a way to catch any error?

It won’t fail badly - it can fail to do anything at all if there is no view controller that can be dismissed.