title: Swift: 'use of unresolved identifier'- how to alter a variable and use that variable in different functions?
body: <p>I need to have this button that I have created (a blue button) alter a variable (named <code>playerMark</code>) that I create and use earlier in another code block in my code. </p>
  
  <p>Here is where <code>playerMark</code> is introduced and is used: </p>
  
  <pre><code>func setImgforCircle(spot:Int, player:Int) {
          var playerMark = player == 1 ? "Red_x" : "Red_o"
  
      plays[spot] = player
      switch spot {
      case 1:
          circle1.image = UIImage(named: playerMark)
      case 2:
          circle2.image = UIImage(named: playerMark)
      case 3:
          circle3.image = UIImage(named: playerMark)
      case 4:
          circle4.image = UIImage(named: playerMark)
      case 5:
          circle5.image = UIImage(named: playerMark)
      case 6:
          circle6.image = UIImage(named: playerMark)
      case 7:
          circle7.image = UIImage(named: playerMark)
      case 8:
          circle8.image = UIImage(named: playerMark)
      case 9:
          circle9.image = UIImage(named: playerMark)
  
      default:
          circle2.image = UIImage(named: playerMark)
      }
  
  }
  </code></pre>
  
  <p>I have an IBAction named <code>blueBtnClicked</code> hooked up to my blue button that I need to execute:</p>
  
  <pre><code>playerMark = player == 1 ? "Blue_x" : "Blue_o"
  </code></pre>
  
  <p>but the console does not "remember" the variables (playerMark and player) and I get the error, 'use of unresolved identifier.' Here is the <code>blueBtnClicked</code> block:</p>
  
  <pre><code>@IBAction func blueBtnClicked(sender: UIButton) {
          gameboard.image = UIImage(named: "Blue_gb")
          resultsView.image = UIImage(named: "Blue_results")
          colorsView.image = UIImage(named: "Blue_Colors")
          colorsBtn.setTitleColor(UIColor.lightTextColor(), forState: UIControlState.Normal)
          resetBtn.setTitleColor(UIColor.lightTextColor(), forState: UIControlState.Normal)
      }
  </code></pre>
  
  <p>What can I do to to alter the playerMark variable when certain buttons are clicked? Please explain all answers very thoroughly as I am new to Swift. </p>