I am developing an iOS quiz app and i want it to where if the user selects a wrong answer it segues to the wrong answer view. However in my current code when I run the simulator and click a wrong answer choice I get

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'wrongViewSegue'' *** First throw call stack:

and the simulator ends. How could I make it to where I don't get an error and the wrong answer view is shown after a user selects the wrong answer choice?

Here is my code:

//wrong view segue
func wrongSeg() {

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

}


//variables
var rightAnswerBox:UInt32 = 0
var index = 0



//Question Label
@IBOutlet weak var questionLabel: UILabel!

//Answer Button
@IBAction func buttonAction(_ sender: AnyObject) {

if (sender.tag == Int(rightAnswerBox)) {

    //removes asked question



print ("Correct!")
}

else if (sender.tag != Int(rightAnswerBox)) {


print ("Wrong!")
    wrongSeg()
    }

    randomQuestion()

}

override func viewDidAppear(_ animated: Bool)
{
questionWithAnswers()


}






func questionWithAnswers() {

    //random question function
    randomQuestion()





}




override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
1  
Check your storyboard I think you are actually missing the segue called wrongViewSegue from your current ViewController to your WrongViewController – Reinier Melian 3 hours ago
    
Correct! Thank you – Captain Code 1 hour ago

1 Answer 1

Receiver () has no segue with identifier 'wrongViewSegue'.

First of all create segue with view controller to view controller and then, name it like below gif.

enter image description here