Im trying to save an object to `NSUserdefaults` and then extract the same object.

```
//        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()

```

In this piece of code I save the object Report into `NSUserDefaults` encoded to `NSData`. `DayReport` is the type of `Report`

But when I switch the comment sections so the upper part of the code is not commented and the lower part is, the `let var = (nil)` and the program crashes. **Why?**

`DayReport` has the `NSCoding` protocol.

Update
------

I added this:

```
    defaults.setObject(data, forKey: "testKey")
    defaults.synchronize()

    println(defaults.objectForKey("testKey"))

```

And it prints out nil, so it isnt getting saved properly but the data is not nil.