TLDR: I need to manipulate a different navigation stack than what the user is currently on, so that when the different stack is shown, it's always on it's root view controller.
I am working on a SWIFT e-commerce project where the user can at any point tap a cart BarButtonItem to pop-up a view controller that shows their shopping cart. This cart is shown using the code below:
let cartController: CartNavigationController = self.storyboard!.instantiateViewController()
self.navigationController!.present(cartController, animated: true, completion: nil)
There is a certain special product that is key to my logic on a specific tabBarItem navigation stack. I want to make sure that if the user deletes this product from their cart, that this specific tabBarItem navigation stack is at it's root view controller when the cart view controller is dismissed.
I know this can be achieved pretty easily by passing a variable between two view controllers. The problem is that I have no way of knowing which viewcontroller accessed the cart, or even which tab the user is currently on, as the cart is accessible from all view controllers.
I've tried a bunch of methods here, but none of them work. Trying to use the completion handler on the self.dismiss() doesn't seem to do anything. I've tried accessing presentingViewController and presentedViewController to manipulate the destination stack after dismissal, but with no luck yet.
Hopefully that made sense. Is this possible? Thanks.