title: I cannot make NSUserdefaults work for me as expected
body: <p>I'm developing the application that allows users to vote once a day. To set up that time limit I declare votingStatus Boolean variable. Its value depends on controlDate that can be "nil" if first time running the app and then votingStatus is true. </p>
  
  <p>However the application doesn't work properly. The votingStatus variable changes its value only after reset the application. That is obviously not what I expected. I need the check and update votingStatus variable each time a user clicks the button.</p>
  
  <p>Thank you in advance for sharing your minds how to correct the application flow!</p>
  
  <p>Below the code I wrote inside class ViewController: UIViewController { }</p>
  
  <pre><code>var votingStatus: Bool?
  
  @IBAction func yesButtonPressed(sender: AnyObject) {
  
      //Check if votingStatus is true
      if votingStatus == true {
          //I'm using Parse for backend
          var score = PFObject(className: "score")
          score.setObject(1, forKey: "vote")
          score.saveInBackgroundWithBlock{
              (succes: Bool!, error: NSError!) -&gt; Void in
              if succes == true {
                  println("Done with ID \(score.objectId)")
                  //update NSUserdefaults
                  NSUserDefaults.standardUserDefaults().setObject(NSDate(), forKey: "controlDate")
                  // should I NSUserDefaults.standardUserDefaults().synchronize() below?
              } else {
                  println(error)
                  //show alert
              }
          }
      } else {
          println("Status is \(votingStatus)")
      }
  }
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      // Find if user haven't already voted within 1 day so if his/her voting status true
      // var votingStatus: Bool?
  
      //To retrive the control date value. First time it has nil value
      var controlDate = NSUserDefaults.standardUserDefaults().objectForKey("controlDate") as? NSDate
      var timeInterval = controlDate?.timeIntervalSinceNow
      var dayInSeconds = 24.0 * 3600
  
      if controlDate == nil {
          votingStatus = true
      } else {
          if timeInterval &lt; dayInSeconds {
              votingStatus = false
          } else {
              votingStatus = true
          }
      }
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  </code></pre>