I am having a problem with passing data between ViewControllers as an action. This shall mean following:
ViewController1 - NavigationControllers, etc. - ... | | ViewController2 - - - - - - ...
So I have two ViewControllers. ViewController1 has a variable (let's say var myName:String = "Joana") and I want to change it by clicking on a button in the ViewController2. My question is: How can I do that (I know how to pass data between VCs which are directly connected via a segue, but not combined with an action, that's my problem)? I've heard of prepare(for segue: UIStoryboardSegue, sender: Any?), but I think that it only works if there exists a segue (directly) between both VCs. Summarised:
VC2: Button: action -> change var 'myname' on VC1 to 'hello', no direct segue.
Thanks for your help in advance! :-)