In a file called Menu, I have this:
class Menu: UIViewController {
var no_of_swipes = 99
@IBAction func pressedThreeSwipes(sender: AnyObject) {
no_of_swipes = 3
}
}
And in another file I have this: class Game: UIView {
func didMoveToView(view: UIView) {
/* Setup your scene here */
var swipes = Menu()
var no_of_swipes: Int = 0 {
didSet {
println("\(swipes.no_of_swipes) should be three")
}
}
}
However when I press the button in Menu, triggering a segue that moves to the second file. The console states that no_of_swipes
= 0. In // line x, if I remove = 0, I receive an error about having an initialiser. So, my question is: why isn't no_of_swipes 3? I think this is a problem either with obtaining no_of_swipes or with the observer.
Thank you in advance