I know that normally, when a UIViewController A
presents another UIViewController B
, the presentedViewController
property of A
is set to B
. So A
in retained in memory.
Simply, I want to A
to present B
, but then have A
get cleaned up as it will never be returned to.
For a more complete explanation and rationale, in my app I have a UINavigationController that may have a bunch of screens in the hierarchy. At some point (e.g. the use logs out), I want to present a new view controller (login) by calling self.present(loginViewController, animated: true, completion: nil)
. However, there is no chance the app will ever come back to the UINavigationController by calling "dismiss" from the login controller. If a login is performed, the login view controller will "present" a new UINavigationController.
I want the original UINavigationController and all of its hierarchy to get cleaned up as there might be many screens in the hierarchy seemingly that will never get used again.
(Also, in this case, when the user started the app, they were "auto logged in", so the UINavigationController is the root controller. And as such, when logging out, it can't "dismiss" itself to back to the login screen.)
Thanks!