title: Extract notification userinfo in a mixed language project
body: <p>I am working on a mixed language project, combining both Objective C and Swift in XCode 6.</p>
  
  <p>In this project, the Singleton (Objective C) class posts a notification which is then received by ViewController (Swift).</p>
  
  <p>Singleton.h</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  NSString *const notificationString = @"notificationString";
  
  @interface Singleton : NSObject
  
  + (id)sharedSingleton;
  
  - (void)post;
  
  @end
  </code></pre>
  
  <p>Singleton.m</p>
  
  <pre><code>#import "Singleton.h"
  
  static Singleton *shared = nil;
  
  @implementation Singleton
  
  - (id)init {
      self = [super init];
      if (self) {
  
      }
      return self;
  }
  
  #pragma mark - Interface
  
  + (Singleton *)sharedSingleton {
      static dispatch_once_t pred;
  
      dispatch_once(&amp;pred, ^{
          shared = [[Singleton alloc] init];
      });
  
      return shared;
  }
  
  - (void)post {
      char bytes[5] = {5, 7, 9, 1, 3};
  
      NSDictionary *objects = @{@"device":[NSData dataWithBytes:bytes length:5], @"step1":[NSNumber numberWithInt:4], @"step2":[NSNumber numberWithInt:7]};
  
      [[NSNotificationCenter defaultCenter] postNotificationName:notificationString
                                                          object:self
                                                        userInfo:objects];
  }
  
  @end
  </code></pre>
  
  <p>Of course, in this mixed-language project, bridging header must be setup correctly (just by adding <code>#import "Singleton.h"</code> in it)</p>
  
  <p>ViewController.swift</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      let singleton = Singleton.sharedSingleton() as Singleton
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
  
          NSNotificationCenter.defaultCenter().addObserver(self, selector: "action:", name: notificationString, object: nil)
  
          singleton.post()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
  
  
      }
  
      // MARK: - Notification
  
      func action(notification: NSNotification) {
          let userInfo = notification.userInfo as Dictionary&lt;String, String&gt; // things go wrong here?!
          let hash = userInfo["device"]
          let completed = userInfo["step1"]
          let total = userInfo["step2"] 
  
      }
  
  }
  </code></pre>
  
  <p>This makes no compilation error. However, at run time, XCode reports: </p>
  
  <blockquote>
    <p>fatal error: dictionary cannot be bridged from Objective-C</p>
  </blockquote>
  
  <p><code>notification.userInfo</code> contains an NSDictionary built by <code>NSSTring: NSData</code>, <code>NSSTring: NSNumber</code>, <code>NSSTring: NSNumber</code> while this command <code>let userInfo = notification.userInfo as Dictionary&lt;String, String&gt;</code> is trying to convert to <code>Dictionary&lt;String, String&gt;</code> </p>
  
  <p>Does this cause the fatal error?</p>
  
  <p>In <code>ViewController.swift</code>, what should I do to "read" NSDictionary passed in <code>notification.userInfo</code>, sent from <code>Singleton.m</code>?</p>
  
  <p>Thanks in advance</p>