I want to call a method by using NSNotificationCenter .They do not call in Swift 2.0. I am newer in Swift . Please help . Any help would be apperciated.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let landingView = NewsViewController(nibName : "NewsViewController", bundle: nil)
NSNotificationCenter.defaultCenter().postNotificationName("NotificationIdentifier", object: nil)
self.navigationController?.pushViewController(landingView, animated: true)
}
In my News Controller
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "methodOfReceivedNotification:", name:"NotificationIdentifier", object: nil)
}
func methodOfReceivedNotification(notification: NSNotification){
}
override func viewWillDisappear(animated: Bool) {
NSNotificationCenter.defaultCenter().removeObserver(self, name: "NotificationIdentifier", object: nil)
}