I have a project in which I have a storyboard. The storyboard contains several view controllers. I'll simplify it and omit the unnecessary details. Within a Navigation Controller, there are several UIViewControllers hooked up with segues. (see screenshot below...)
From left to right on the bottom row it goes Navigation Controller ➞ VC1 ➞ VC2. VC1 also has a manual segue to VC3 on the top row which goes VC3 ➞ VC4. VC1 is the starting view controller of the app. There two segues connecting from VC1. The segue from VC1 ➞ VC2 is the primary segue and from VC1 ➞ VC3 is the secondary. The secondary segue will be called programmatically when the user runs the app for the first time as a sort of welcome/getting started sequence.
I set this up going off of this post here, referencing the second most upvoted post in which the user suggests a segue between the starting VC file itself and the view of the other VC and then calling performSegueWithIdentifier.... here is the problem.
When running this app, there are no compile-time errors. It all looks good. It loads up, and I have this set to go in the view did load, which for now I am forcing it to run as if it were the first time like so...
override func viewDidLoad() {
super.viewDidLoad()
let firstVisit = true
if firstVisit == true {
self.performSegueWithIdentifier("welcomeSegue", sender: self)
}
// Do any additional setup after loading the view.
}
So it loads up. I can tell it attempts to show VC1 before VC3 promptly gets pushed on top as desired. VC3 is displayed, brilliant. The issue occurs when I press the one and only button on VC3 that should perform a typical segue from VC3 ➞ VC4. This is when I get the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<X.VC1>) has no segue with identifier 'welcomeSegue''
Now the strange thing to me that I cannot figure out is that, even though VC3 has been properly presented, it is VC1 that this error originates from as denoted by the Receiver (<X.VC1>)
. I'm stumped. All of the errors I have found online show other solutions that have not worked for me. If you don't believe me when I say I know the spelling is right, A) It properly loaded the view controller, B) here is a screenshot anyway.
I DUN GET IT :[ Let me know if you have advice. Thanks all.
** AGAIN, JUST AS A REMINDER, THIS APP DOES PROPERLY LOAD AND DISPLAY VC3 AS IT SHOULD. THE ERROR OCCURS AFTERWARDS WHEN I ATTEMPT TO SEGUE TO VC4 BUT THAT SEGUE IS NORMAL THROUGH INTERFACE BUILDER WITH NO IDENTIFIER BECAUSE IT WILL NEED NO LINK TO THE CODE AS THE SEGUE TO VC3 DOES.
EDIT: Here is a sample project that functions properly. I cannot distinguish a difference that sets mine apart.
EDIT #2: I admit to making a dumb mistake. The marked solution has found it and corrected it and the project now functions as desired. Thank you all.