1

I have 2 ViewController, let's say Feed and Login. Initial page is the Feed and if not authenticated, user is getting directed to Login page. After filling the form, on successful login, I am trying to unwind back to Feed page.

In FeedVC, I added:

@IBAction func unwindToFeed(segue: UIStoryboardSegue){

}

In LoginVC, on login-button press

@IBAction func loginButton(sender: AnyObject) {
  func authenticatedUser (...) {

    if error != nil {
          // error handling
    } else {
         // success

        NSOperationQueue.mainQueue().addOperationWithBlock({
           self.performSegueWithIdentifier("unwindToFeed", sender: self)
        })
    }
  } 
}

However, on success, it doesn't get unwind-ed, and I'm getting an error

Terminating app due to uncaught exception 'NSInvalidArgumentException', > reason: 'Receiver ( 0x7fd789a2cab0>) has no segue with identifier 'unwindToFeed''

In Storyboard, in LoginVC, I also tried to ctrl+dragging from Yellow (ViewController) to Exit, at the top. However as soon as I do that, I receive "Segues initiated directly from view controllers must have an identifier" and in Login View Controller Scene it shows Unwind segue to 'Exit'.

What am I doing wrong?

Cœur
  • 37,241
  • 25
  • 195
  • 267
senty
  • 12,385
  • 28
  • 130
  • 260
  • Possible duplicate of [Programmatically unwind segue](https://stackoverflow.com/questions/30815040/programmatically-unwind-segue) – Cœur Dec 29 '18 at 02:15
  • Possible duplicate of [How to perform Unwind segue programmatically?](https://stackoverflow.com/questions/12509422/how-to-perform-unwind-segue-programmatically) – Cœur Dec 29 '18 at 02:16

1 Answers1

0

Found my answer. I didn't name the segue as it said.

Solution: Click on "Unwind segue to 'Exit'", on right panel, 'Storyboard Unwind Segue', you will see.

senty
  • 12,385
  • 28
  • 130
  • 260