1
votes

I am trying to create an unwind segue that takes me back two viewControllers, and I thought I had everything set up correctly, but it crashes with no error printed when I perform the segue...

Here's what I've done:

In the DESTINATION viewController, we'll call it VC1 (bottom of the stack) I created this action:

@IBAction func unwind(segue:UIStoryboardSegue){}

In the interface builder I hooked up VC3 (the third view controller up) to the unwind segue via the exit button and named it "unwind".

I call perform for segue like so:

performSegue(withIdentifier: "unwind", sender: self)

Here is the view controllers and segue identifier

http://imgur.com/a/gJPYQ

The "Delete Trip" button calls the segue AFTER all the other logic has been taken care of.

As soon as that is called, my app crashes with no error message and shows me the AppDelegate screen. What's going on?

2
This kind of crashes mainly caused by wrong identifiers. Are you sure you are using right identifier?Mohammadalijf
Also are you doing anything on prepareForSegue?Mohammadalijf
The identifier is "unwind" in the storyboard too. No, nothing in prepareForSegue.Cody Lucas
I guess that if you print something in your unwind segue function it doesn't show up in the console?Marie Dm
Maybe a storyboard screenshot could help.Marie Dm

2 Answers

-1
votes

If you pushed your VC, you could use:

navigationController?.popToRootViewControllerAnimated(true)
-1
votes

If you have two VC's presented modally, then you will need to dismiss two VC's modally. Use: dismiss(..., completion: { dismiss(..., completion: nil)

Your current "unwind" segue is simply presenting the original one again..and maybe you don't have identifiers set up correctly or you are overlooking your view hierarchy.