Everything was fine with iOS7 and Xcode and 5 - and after the upgrade to Xcode 6 and so iOS8, there is a sudden crash in the application where it was always working fine.
The error shown when it crashes is:
Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'adding a root view controller as a child of view controller:'
I managed to find the single line creating the issue:
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:4] animated:YES];
The app adds views up to 8 whilst doing the exercise ; and when the exercise is done, just coming back to the last view which was the menu of the exercise so 4. A bit hard-coded but simple and efficient as it is always the case.
and I have no idea was the popToViewController is doing that.
Any help or thoughts would be greatly appreciated.
I finally found a solution that works - so here it is before for completion / records:
UINavigationController* savedUinvc = self.navigationController;
UIViewController *one = nil;
one = [savedUinvc popViewControllerAnimated:NO];
UIViewController *two = nil;
two = [savedUinvc popViewControllerAnimated:NO];
UIViewController *three = nil;
three = [savedUinvc popViewControllerAnimated:YES];