0

Currently playing around with my a viewcontroller. So the thing is, instead of me having the controls in the top, I want to make my own custom previous button. I figured that the below code is what i should use:

@IBAction func previousButtonTapped(sender: UIButton) {
    self.navigationController?.popViewController(animated: true)
}

It makes an error, Expression of type 'UIViewController?' is unused.

I went ahead and figured that I could use _ = before self. However I get a Thread 1: signal SIGABRT. So really, I don't know what I'm doing wrong here.

TWOF
  • 388
  • 3
  • 14
  • do you actually have a navigation controller? – Eugene Gordin Oct 03 '16 at 22:32
  • Yes i do, actually i followed this tutorial: https://www.youtube.com/watch?v=TQjH5qHwU6Y&list=PLoN_ejT35AEgP1y2tkOTYOKOFHXUBkH2z&index=3 You can skip to around 8 minutes –  Oct 03 '16 at 22:33
  • I think that tutorial is not in Swift 3, that's why you're getting that warning on the first place: http://stackoverflow.com/questions/37843049/xcode-8-swift-3-expression-of-type-uiviewcontroller-is-unused-warning – Eugene Gordin Oct 03 '16 at 22:42
  • thats the exact post i read, which made me use _ =, but i still get a SIGABRT error –  Oct 03 '16 at 22:44
  • have you tried this: if self.navigationController != nil { self.navigationController!.popViewController(animated: true) } – Eugene Gordin Oct 03 '16 at 22:44
  • yea, still get the SIGABRT –  Oct 03 '16 at 22:47
  • what does the call stack show when you get this error? – Eugene Gordin Oct 03 '16 at 22:48
  • check if you connected the outlets/actions correctly in your storyboard – Eugene Gordin Oct 03 '16 at 22:50
  • 0x1079b5f34 <+159>: movq 0xe81325(%rip), %rbx ; (void *)0x00000001074f9d20: objc_release Don't know if this tells anything? Doublechecked my connections in the storyboard, and they are fine, no doubles –  Oct 03 '16 at 22:51
  • the call stack is what's showing in the left-side panel, when you get this crash. It basically shows every method that was executing prior to the crash. – Eugene Gordin Oct 03 '16 at 22:53
  • I have no idea what i should benefit from this call stack, its just a bunch of numbers. –  Oct 03 '16 at 23:00
  • well, that thing is for a reason there, for people to look and see if the methods they expect to be called were called as well as going step by step backwards checking if all the values they expect to be passing are passing correctly. In your case, something is definitely wrong. – Eugene Gordin Oct 03 '16 at 23:02
  • have you tried to place a breakpoint inside of the previousButtonTapped method and see the values of the objects there, if everything is not nil ? – Eugene Gordin Oct 03 '16 at 23:03
  • my gosh, this is embarresing.. 1st day with xCode i must say though.. But i found the method that conflicted after all, and you are right, by some reason my outlet was wrong.. I just deleted it, and made the connection again. - now it works! –  Oct 03 '16 at 23:07
  • ;) you see...extra pair of eyes is always good – Eugene Gordin Oct 03 '16 at 23:09
  • Appreciate it mate! :-) –  Oct 03 '16 at 23:11

0 Answers0