I'm trying to change a method in ViewDidLoad with this code:
In class declaration:
var nextValue: Int!
And in ViewDidLoad:
if nextValue == nil {
print("Hi")
} else if nextValue == 2 {
print("Hello")
}
And finally this function that changes the value of nextValue:
func buttonAction(sender: AnyObject) {
self.performSegueWithIdentifier("nextView", sender: self)
nextValue = 2
}
When I move back from "nextView" to the first view nextValue should be 2 but it is nil. What am I doing wrong?