Obviously, as many have said, this in the world of textbooks would / should be a delegate problem. Where A represents B and B represents C Then, when C is executed, it tells B which rejects C , and then B tells A reject B
I would say that you essentially create a set of modally represented view controllers that make up the navigation stack. I would most likely implement it as such. Where A will be the root view controller. A then pushes B onto the stack, and B will push C onto the stack. When C was executed, it could just popToRootViewControllerAnimated: or popToViewController:A animated:YES if A not rootViewController.
Also, removing B from under C seems problematic. But this does not sound as shown on the stone based on your comment:
But in any case, this is not the end of the world if I keep this viewController there for a while. -
This will at least set a fairly clean delegate setting.
It still seems that you basically know that when the user has finished using C , they will no longer need B If so, you can blindly fire two or more dispatchers at once. And the code for two is pretty simple at the same time. (assuming iOS version> 5.0)
[self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES]
Please note that I said blindly! This code does not forgive and makes assumptions. For example, it is most obvious that the view manager actually has a presentingViewController and that this view controller has a presentingViewController . If any of these criteria is not met, this code will be nothing . This can easily happen if you restructure your application at some point.
So, if you decide to use this line of code, use it very carefully. And please consider using the UINavigationController for this view hierarchy, or at least for delegation.