0
I have a class Main
in my application, and in it I have created the variable cod
which receives the value of 0
, in this class I also have a sequence of buttons that in them contain the event of changing the value of cod
for, 1
, 2
or 3
, and clicking after the click on the button, the application is changed to another layout. In that other layout, matched by another class called Resultado
, I need to access the value of cod
, but when I use the var dados = Main().cod
, it returns me the value of 0
, i.e. as long as the buttons have the cod = 1
, 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 resulting class
var dados = Main().cod
what I’m doing wrong that I can’t access the altered value of cod
?