Given:
- ViewController A that presents ViewController B
- ViewController B has no reference to ViewController A (except implicitly the
presentingViewControllerproperty) - ViewController B calls
dismisson itself and does nothing else
What I want to achieve:
- ViewController A wants to know when ViewController B got dismissed in order to clean up some state
Restrictions:
- I do not want to use KVO
- I do not want to modify ViewController B or its behavior in any way
What I have found out so far:
dismiss(animated:completion:)according to the documentation forwards the call to itspresentingViewController. But as it seemsdismiss(animated:completion:)is not called, but rather a private method_performCoordinatedPresentOrDismiss:animated:.- iOS documentation on
presentingViewControlleris misleading. It says "the view controller that was presented has this property set to the view controller that presented it", but that's not true. In iOS 11, this will always point to the root parent VC of the VC thatpresentwas called on. Similarly the documentation onpresentedViewControlleris misleading. It says "the view controller that called the method has this property set to the view controller that it presented", that's not the whole story. Every VC in the hierarchy of the VC (all its parent VCs and child VCs) that calledpresentwill point to the samepresentedViewController.