blob12 blob12 - 3 months ago 7x
iOS Question

Swift Error: "...whose view is not in the window hierarchy." performseguewithidentifier

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:

if (index < workouts2.endIndex-1) {

else {
performSegueWithIdentifier("endWorkout", sender: self)

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: whose view is not in the window hierarchy!

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!


the message "whose view is not in the window hierarchy" because the code still execute while your already transition to another view. try call return or break after performSegueWithIdentifier to stop the loop