kotowo
3/11/2016 - 1:05 AM

NotificationCenter1.swift

// add observer
NSNotificationCenter.defaultCenter().addObserver(self, selector: "receive:", name:"KEY STRING", object: nil)

// remove observer
NSNotificationCenter.defaultCenter().removeObserver(self)

// notification selector
func receive(notification: NSNotification?) {
  let userInfo = notification.userInfo
  print(userInfo)
}
func postNotification() {
  let userInfo = ["key" : "value"]
  let inAppNotification = NSNotification(name:"KEY STRING", object: nil, userInfo: userInfo)
  NSNotificationCenter.defaultCenter().postNotification(inAppNotification)
}