I use the addObserver
API to receive notification:
NSNotificationCenter.defaultCenter().addObserver(self, selector: \"methodOFReceivedNotication:\",
Just mark it with the dynamic
modifier or use the @objc
attribute in your method declaration
dynamic private func methodOFReceivedNotication(notification: NSNotification){
//Action take on Notification
}
or
@objc private func methodOFReceivedNotication(notification: NSNotification){
//Action take on Notification
}
Have you considered using -addObserverForName:object:queue:usingBlock:
?
NSNotificationCenter.defaultCenter().addObserverForName("NotificationIdentifier", object: nil, queue: nil, usingBlock: {
[unowned self] note in
self.methodOFReceivedNotication(note)
})
or instead of calling the private method, just performing the action.
NSNotificationCenter.defaultCenter().addObserverForName("NotificationIdentifier", object: nil, queue: nil, usingBlock: {
[unowned self] note in
// Action take on Notification
})