title: How do I convert an NSDictionary to a Swift Dictionary<String, NSObject>?
body: <p>I am rewriting an Objective-C class in Swift to get a feel for the language. In Objective-C my class included the following method:</p>
  
  <pre><code>- (id) initWithCoder:(NSCoder *)aDecoder
  {
      return [self initWithActionName:[aDecoder decodeObjectOfClass:[NSString class] forKey:@"actionName"]
                              payload:[aDecoder decodeObjectOfClass:[NSDictionary class] forKey:@"payload"]
                            timestamp:[aDecoder decodeObjectOfClass:[NSDate class] forKey:@"timestamp"]];
  }
  </code></pre>
  
  <p>After some trial and error with the compiler, I managed to rewrite it like this:</p>
  
  <pre><code>convenience init(aDecoder: NSCoder) {
      let actionName = aDecoder.decodeObjectOfClass(NSString.self, forKey: "actionName") as NSString
      let payload = aDecoder.decodeObjectOfClass(NSDictionary.self, forKey: "payload") as NSDictionary
      let timestamp = aDecoder.decodeObjectOfClass(NSDate.self, forKey: "timestamp") as NSDate
      self.init(actionName: actionName, payload: payload, timestamp: timestamp)
  }
  </code></pre>
  
  <p>However, this still gives me an error on the last line: “Could not find an overload for <code>init</code> that accepts the supplied arguments.” The method signature of <code>init</code> is</p>
  
  <pre><code>init(actionName: String, payload: Dictionary&lt;String, NSObject&gt;, timestamp: NSDate)
  </code></pre>
  
  <p>so I assume the problem is that I am trying to pass an <code>NSDictionary</code> instead of a <code>Dictionary&lt;String, NSObject&gt;</code>. How can I convert between these two not-quite-equivalent types? Should I just be using <code>NSDictionary</code> for all of the code that has to interact with other Objective-C components?</p>