title: How Can I Save A Boolean In NSDefaults When A Button Is Pressed?
body: <p>I've coded a night and day button theme. If the user presses the day button, <code>GlobalData.DayBool = true</code>, and <code>GlobalData.NightBool = false</code>. When they press the night button, <code>GlobalData.DayBool = false</code> and <code>GlobalData.NightBool = true</code>. The background changes to night or white, depending on which one is true and false.</p>
  
  <p>Let's say that the user clicks the Night Button. <code>GlobalData.NightBool = true</code>, and <code>GlobalData.DayBool = false</code>, and the background changes to black. </p>
  
  <p>I want the booleans to be saved depending on which button they press, so that when they close the app, their background will be the same as they had selected.</p>
  
  <pre><code>//Day Button Pressed
  for touch: AnyObject in touches {
  
      let location = touch.locationInNode(self)
  
      if dayButton.containsPoint(location) {
  
          for touch: AnyObject in touches {
              _ = touch.locationInNode(self)
  
              backgroundColor = GlobalData.dayColor
              GlobalData.nightBool = false
              GlobalData.dayBool = true
          }
      }
  }
  
  //Night Button Pressed
  for touch: AnyObject in touches 
      let location = touch.locationInNode(self)
  
      if nightButton.containsPoint(location) {
  
          for touch: AnyObject in touches {
              _ = touch.locationInNode(self)
  
              backgroundColor = GlobalData.nightColor
              GlobalData.nightBool = true
              GlobalData.dayBool = false 
          }
      }
  }
  </code></pre>
  
  <p>Here's my code for when it switches backgrounds depending whether one of them is true or false: </p>
  
  <pre><code>//Day Background
  if GlobalData.dayBool == true &amp;&amp; GlobalData.nightBool == false {
      backgroundColor = GlobalData.dayColor
  }
  
  //Night Background
  if GlobalData.nightBool == true &amp;&amp; GlobalData.dayBool == false {
      backgroundColor = GlobalData.nightColor
  }
  </code></pre>
  
  <p>Please leave any questions below if you have any. I really need help on this.</p>