title: How to pass data using NotificationCenter in swift 3.0 and NSNotificationCenter in swift 2.0?
body: <p>I'm implementing <code>socket.io</code> in my swift ios app. </p>
  
  <p>Currently on several panels I'm listening to the server and wait for incoming messages. I'm doing so by calling the <code>getChatMessage</code> function in each panel:</p>
  
  <pre><code>func getChatMessage(){
      SocketIOManager.sharedInstance.getChatMessage { (messageInfo) -&gt; Void in
          dispatch_async(dispatch_get_main_queue(), { () -&gt; Void in
              //do sth depending on which panel user is
          })
      }
  }
  </code></pre>
  
  <p>However I noticed it's a wrong approach and I need to change it - now I want to start listening for incoming messages only once and when any message comes - pass this message to any panel that listens to it.</p>
  
  <p>So I want to pass the incoming message through the NSNotificationCenter. So far I was able to pass the information that something happened, but not pass the data itself. I was doing that by:</p>
  
  <pre><code>NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ViewController.showSpinningWheel(_:)), name: showSpinner, object: nil)
  </code></pre>
  
  <p>then I had a function called: </p>
  
  <pre><code>func showSpinningWheel(notification: NSNotification) {
  }
  </code></pre>
  
  <p>and any time I wanted to call it I was doing:</p>
  
  <pre><code>NSNotificationCenter.defaultCenter().postNotificationName(hideSpinner, object: self)
  </code></pre>
  
  <p>So how can I pass the object <code>messageInfo</code> and include it in the function that gets called?</p>