Swift Error: "...whose view is not in the window hierarchy." performseguewithidentifier
<p>I want the app to move to the end screen once the last index of the array is reached. This is what I have for the code where "endWorkout" is the modal segue identifier:</p>

<pre><code>if (index &lt; workouts2.endIndex-1) {
        index++;}

else {
        timerLabel.pause();
        timerLabel.reset();
        performSegueWithIdentifier("endWorkout", sender: self)
        println("Hello")}
</code></pre>

<p>The app transitions to the End Workout screen just fine but I get a non-stop loop of the following error in the xcode console: <strong> whose view is not in the window hierarchy!
Hello</strong></p>

<p>It also keeps printing out the print statement "Hello" which should be printed only once. The other solutions I've read suggest that the performSegueWithIdentifier should be in the method "viewDidAppear" but I need it to be inside the conditional block in this particular method since the screen should appear at the end of the entire workout routine. What am I doing wrong? Thanks!</p>