When you use the presentViewController:animated:completion:
method from controller A
to present controller B
modally, what happens is that the presentedViewController
property of A
is set to controller B
, and the presentingViewController
property of B
is set to A
. Thus, both controllers are kept in memory while the presentation is taking place.
When you go from B
to A
, you call dismissViewControllerAnimated:completion:
on A
via the presentingViewController
property of B
, like this:
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
(You can also call [self dismissViewControllerAnimated:YES completion:nil]
and the system will automatically forward the request to the presenting view controller.)
After that, the presentedViewController
property of A
will be set to nil
and, consequently, it will be subject to memory deallocation by the system, provided that there isn't any other strong pointer pointing to it.