I'm working on iOS app and sometimes I need to jump on the second view of my application, but exactly on the state of the view I've left it. I've found out that popToViewController is suitable for this operation. My question is : What happens with other views? Are they killed or are they still alive in the background? For navigation between views I'm using navigationController. Thank you.
3 Answers
NavigationController is working like stack. When you are popping something it's being deallocated. For example view controllers stack like this:
A -> B -> C -> D
If you will call popToViewController(B) the stack should be:
A -> B
View controllers C and D should be deallocated, of course if they don't have strong references that keep them in the memory ;)

- 2,734
- 1
- 20
- 23
Navigation controller works on stack when we push and pop view controller.When we push a view controller then view insert in stack and when we pop a view its remove from stack.As all we know that stack is working on First In First Out Rule.
popviewcontoller pop a single viewcontoller from navigation stack.If you want to pop a specific viewcontoller then on basis of index of that controller in stack you can directly navigate on it.

- 1,310
- 1
- 18
- 31
Navigation controller maintains a navigation Stack for every view controller, every controller live on the stack until it pops, the one on the window is topViewController.
When you call popToViewController all viewController in between are get pop from navigation stack will release from the memory, assumed that no other class is holding that view controller strongly.

- 1,113
- 12
- 27