title: Swift NSCoding Not working
body: <p>I'm having trouble using <code>NSCoding</code> in Swift. I have attempted to implement the protocol but I get a crash whenever I call my <code>save()</code> method. Xcode pulls me up on the line  in <code>encodeWithCoder</code>. Here's my code, any suggestions would go along way.</p>
  
  <pre><code>class CourseList: NSObject, NSCoding {
      ...
  
      init(coder aDecoder: NSCoder!){
          super.init()
          if aDecoder != nil {
              self.courses = aDecoder.decodeObjectForKey("courses") as Dictionary&lt;String,course&gt;
          }
      }
  
      func encodeWithCoder(aCoder: NSCoder!) {
          aCoder!.encodeObject(self.courses, forKey: "courses") // EXC_BAD_INSTRUCTOIN
  
  
      }
  }
  </code></pre>
  
  <p>I wrote <code>save()</code> and <code>load()</code> to call in a <code>ViewController</code>.</p>
  
  <pre><code>func save() {
      var archivedObject = NSKeyedArchiver.archivedDataWithRootObject(History)  //NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
      var defaults = NSUserDefaults.standardUserDefaults()  //[defaults setObject:archivedObject forKey:&lt;key_for_archived_object&gt;];
      defaults.setObject(History.courses, forKey: "courses")
      defaults.synchronize()
  }
  
  func load() {
      var defaults = NSUserDefaults.standardUserDefaults()  // NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
      var archivedObject = defaults.objectForKey("courses") as NSData  // NSData *archivedObject = [defaults objectForKey:&lt;key_for_archived_object&gt;];
      History = NSKeyedUnarchiver.unarchiveObjectWithData(archivedObject) as Dictionary&lt;String,course&gt;   //&lt;your_class&gt; *obj = (&lt;your_class&gt; *)[NSKeyedUnarchiver unarchiveObjectWithData:archivedObject];
  
  }
  </code></pre>