title: How to convert NSDictionary to NSObject in Swift?
body: <p>I have a meta variable <code>NSObject</code> in a viewcontroller that I intend to be able to receive any kind of object from the parent viewcontroller that pushes it. I also have a type variable that will determine how I typecast and interpret this <code>NSObject</code> inside the viewcontroller.</p>
  
  <p>The problem is when I tried to cast an <code>NSDictionary</code> into <code>NSObject</code> in the parent, Xcode warns that that type of typecasting will always fail.</p>
  
  <p>Code that I have tried:</p>
  
  <pre><code>childVc.meta = ["title":"test"] as! NSObject; // warning: cast from '[String:String?]' to unrelated type 'NSObject' always fails.
  
  let data = ["title":"test"];
  childVc.meta = data as! NSObject; // warning: cast from '[String:String?]' to unrelated type 'NSObject' always fails.
  
  
  let data = ["title":"test"];
  childVc.meta = data as NSObject; // error: cannot convert value of type '[String:String?]' to type 'NSObject' in coercion.
  
  
  let data = ["title":"test"] as! NSObject; // warning: cast from '[String:String?]' to unrelated type 'NSObject' always fails.
  childVc.meta = data;
  </code></pre>
  
  <p>But the opposite typecasting always works:</p>
  
  <pre><code>let unwrappedMeta = self.meta as! NSDictionary;
  </code></pre>
  
  <p>Oh btw, I know that swift doesn't need semicolon at the end. It's just my habit from obj-c and swift looks like doesn't care about it, so don't let this semicolon distract us. :)</p>