title: Unable to decode a NSObject in Swift
body: <p>I am having a problem decoding an object after I encode it in Swift.</p>
  
  <p>Here is my class:</p>
  
  <pre><code>class Player: NSObject, NSCoding {
  
      var score:Int = 0
  
  init(difficulty: Int!) {
      super.init()
  
  }
  
  
  required init(coder aDecoder: NSCoder) {
      score = aDecoder.decodeObjectForKey("score") as Int
  }
  
  func encodeWithCoder(aCoder: NSCoder) {
      aCoder.encodeObject(score, forKey: "score")
  } 
  </code></pre>
  
  <p>Here is when  I am encoding and decoding:</p>
  
  <pre><code>let data = NSKeyedArchiver.archivedDataWithRootObject(player)
  let newPlayer = NSKeyedUnarchiver.unarchiveObjectWithData(data) as Player
  </code></pre>
  
  <p>It crashes everytime when I try to unarchive it. Anybody have any reasons why?</p>
  
  <p>P.S. I have no idea why my code isn't formatted. I have it indented 4 spaces over! Sorry about that!</p>