I am designing a game with 6 view controllers.
I use modal segues to navigate forward and unwind segues to navigate back.
The game flow through the view controllers is A -> B -> C -> D -> E -> F.
When I try to unwind from F to A dealloc is only called on B and C. This means that each time the game is played the memory used is constantly increasing.
I initially thought the problem was due to something being retained causing dealloc not to be called on view controllers D and E. However, if I set the unwind segue to go from F to D dealloc is called for both F and E which would seem to rule out this as the problem.
I also have a route directly to from view controller A to F. When I unwind in this case dealloc is called on F correctly.
View controllers F and C call the same unwind action on A. I assume this isn't the cause as I have tried changing it to use unique unwind actions for each view controller.
Any thoughts on what is causing this? I have copied some of the code used below. Please let me know what other code (if any) would be helpful in resolving this. Any help would be greatly appreciated.
Unwind action as below:
- (IBAction)unwindToMainMenu:(UIStoryboardSegue *)unwindSegue
{}
Call to trigger unwind segue from view controller F to A:
[self performSegueWithIdentifier:@"ReturnToMainMenu" sender:self];