I am creating a simple quiz app in xcode that has an intro, question, and results view controller. When I try to link my "QuestionViewController" to my "ResultsViewController" with the prepare for segue method in code, the exclamation point in "as!" keyword is not highlighted in pink.. It gives me a "Thread 1: signal SIGABRT". Yes I have linked it in the storyboard previously.
I've tried checking the identifiers of the segues in the storyboard and they look fine. Here is the code I was talking about:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "ResultsSegue" {
let resultsViewController = segue.destination as! ResultsViewController
resultsViewController.responses = answersChosen
}
}
It is supposed to pass the data of answersChosen to my resultsViewController, but I am getting a "Thread 1: signal SIGABRT" error. And like I said, the "!" after "as" is not highlighted in pink like "as" is. In the iBook the "!" is pink.. that indicated to me something is not connected right.
Also in the console:
Could not cast value of type 'UINavigationController'
(0x112186760) to 'CityQuiz.ResultsViewController' (0x10a61e698)
2019-07-01 14:45:35.043824-0400 CityQuiz[29761:429223] Could not
cast value of type 'UINavigationController' (0x112186760) to
'CityQuiz.ResultsViewController' (0x10a61e698)
Isn't it supposed to say cast value of type "QuestionsViewController" instead of "UINavigationController" as well? How else do I check if things are linked properly besides actually clicking on the segues in the storyboard?
Edit #1: Turns out I had an extra navigation controller, that I somehow didn’t notice. I’m new to this, thanks for the responses. I am now getting some “NSUncaughtKeyException” but I found some other posts about those errors.