Swift: How do I safe the value for variable? : so here is a brief explanation of my code: 

    var myVar = 0
    
    if(button image is equal to "mybutton image") {
    
    myVar = 1
    print("It works")
    
    } else {
    
     myVar = 2
    print("Not working")
    }
    
    ButtonPress {
    
    print(myVar)
    
    }

The problem here is that when I run the application I see in the console that it prints "it works" but when I press the button myVar is equal to 0 again so how do I make sure when I press the button myVar will be equal to 1? 
Thank you! 
