title: NSUserDefaults returning nil
body: <p>Im trying to save an object to <code>NSUserdefaults</code> and then extract the same object.</p>
  
  <pre><code>//        let raw: AnyObject! = defaults.valueForKey("testKey")
  //        let data = raw as NSData
  //        
  //        self.Report = NSKeyedUnarchiver.unarchiveObjectWithData(data) as DayReport
  //        
  //        println(Report.Day)
  
  
      Report.Day = "Mon"
  
      let data = NSKeyedArchiver.archivedDataWithRootObject(self.Report)
  
      println(data)
  
      defaults.setObject(data, forKey: "testKey")
      defaults.synchronize()
  </code></pre>
  
  <p>In this piece of code I save the object Report into <code>NSUserDefaults</code> encoded to <code>NSData</code>. <code>DayReport</code> is the type of <code>Report</code></p>
  
  <p>But when I switch the comment sections so the upper part of the code is not commented and the lower part is, the <code>let var = (nil)</code> and the program crashes. <strong>Why?</strong></p>
  
  <p><code>DayReport</code> has the <code>NSCoding</code> protocol.</p>
  
  <h2>Update</h2>
  
  <p>I added this:</p>
  
  <pre><code>    defaults.setObject(data, forKey: "testKey")
      defaults.synchronize()
  
      println(defaults.objectForKey("testKey"))
  </code></pre>
  
  <p>And it prints out nil, so it isnt getting saved properly but the data is not nil.</p>