I've got the following setup:
VC1 -> VC2 -> VC3
VC1 has a button that, when clicked, does a couple of things, then presents VC2.
VC2 has a similar button and presents VC3.
VC3 has a text field and a button. When the button is clicked, a couple of checks are run, then the text field's text should be returned to VC1.
I load the next VC with this code:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc2 = storyboard.instantiateViewController(withIdentifier: "vc2") as! ViewController2
vc2.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
vc2.someinformation = someinformation
self.present(vc2, animated: true, completion: nil)
There's no navigation controller, so I can't use popToViewController.
I also can't use an unwind segue as described here because I have to run a couple of checks before I actually dismiss the current VC and I might have to return to VC2 instead of VC1 (it all depends on the checks' result).
Some people suggest a Coordinator but that seems really complicated (and kind of overkill) for a small and pretty linear app like this.
How do I pass the value back to VC1, while also dismissing both VC3 and VC2? Is there even an easy way to go do VC1 directly, without dismissing to VC2, then using it to return the value to VC1?
Does the solution change if there are 5 VCs and I want to go from e.g. 5 to 2 or 5 to 1 (5 would be the active VC)?