I have a Main
class in my application, and in it I have created the variable cod
that receives the value of 0
, in this class I also have a sequence of buttons that in them contains the event of changing the value of% % , cod
or 1
, and clicking after the click button, the application changes to another layout . In this other layout , matched by another class called 2
, I need to access the value of 3
, but when I use Resultado
, it returns me the value of cod
. even though the buttons have var dados = Main().cod
, the variable is not being changed:
class Main: UIViewController {
var cod = 0
@IBAction func btnSp(sender: AnyObject) {
var storyboard = UIStoryboard(name: "Main", bundle: nil)
var controller = storyboard.instantiateViewControllerWithIdentifier("viewConsultas") as UIViewController
self.presentViewController(controller, animated: true, completion: nil)
cod = 1
}
}
and in the result class
var dados = Main().cod
What am I doing wrong that I can not access the changed value of 0
?