Swift set variable to another ViewController <p>I have two tabs. And i want to set data from one tab to another. For example i have a code that switch to another tab:</p> <pre><code>func foundCode(code: String) { print("Code has been found: \(code)") // MySecondViewController.codeSetter(code); self.tabBarController?.selectedIndex = 1; } </code></pre> <p>What is the best way to set it? Or maybe delegate this variable... But how ?</p>