title: Cannot decode object of class
body: <p><br>
  I am trying to send a "Class" to my Watchkit extension but I get this error.</p>
  
  <blockquote>
    <p><strong>* Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '*</strong>
    -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (MyApp.Person)</p>
  </blockquote>
  
  <p>Archiving and unarchiving works fine on the iOS App but not while communicating with the watchkit extension. What's wrong?</p>
  
  <p>InterfaceController.swift</p>
  
  <pre><code>    let userInfo = ["method":"getData"]
  
      WKInterfaceController.openParentApplication(userInfo,
          reply: { (userInfo:[NSObject : AnyObject]!, error: NSError!) -&gt; Void in
  
              println(userInfo["data"]) // prints &lt;62706c69 7374303...
  
              if let data = userInfo["data"] as? NSData {
                  if let person = NSKeyedUnarchiver.unarchiveObjectWithData(data) as? Person {
                      println(person.name)
                  }
              }
  
      })
  </code></pre>
  
  <p>AppDelegate.swift</p>
  
  <pre><code>func application(application: UIApplication!, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]!,
      reply: (([NSObject : AnyObject]!) -&gt; Void)!) {
  
          var bob = Person()
          bob.name = "Bob"
          bob.age = 25
  
          reply(["data" : NSKeyedArchiver.archivedDataWithRootObject(bob)])
          return
  }
  </code></pre>
  
  <p>Person.swift</p>
  
  <pre><code>class Person : NSObject, NSCoding {
      var name: String!
      var age: Int!
  
      // MARK: NSCoding
  
      required convenience init(coder decoder: NSCoder) {
          self.init()
          self.name = decoder.decodeObjectForKey("name") as! String?
          self.age = decoder.decodeIntegerForKey("age")
      }
  
      func encodeWithCoder(coder: NSCoder) {
          coder.encodeObject(self.name, forKey: "name")
          coder.encodeInt(Int32(self.age), forKey: "age")
      }
  }
  </code></pre>