Reputation: 119
Basically I'm wondering what the proper way to present and release view controllers is.
My original understanding was that ViewControllerA presents ViewControllerB with -presentViewController: Animated: Completion:. Then ViewControllerB can release himself by calling -dismissViewControllerAnimated: Completion:.
Now, if I have three view controllers, A, B and C. A presents B, B presents C, and C returns to to A, how should I write this? I tried to call a dismiss from C on B, but that doesn't work. The only thing that actually seems to work is having C present A again, but is this proper?
Any help would be great, thanks!
Upvotes: 0
Views: 114
Reputation: 104082
No, it is not proper to present A again. This will add a new instance, and as you go forward again to B and C, those will also be new instances. From C, you can either use an unwind segue to go back to A, or you can call dismissViewControllerAnimated:completion
on self.presentingViewController.presentingViewController
. If the first view controller in a series of presenting view controller does a dismissal, it cause all the presented controllers to be deallocated (assuming you aren't holding any other strong reference to them).
Upvotes: 3