3

I'm posting a notification via the default center, like so:

NSNotificationCenter.defaultCenter().postNotificationName(ColorDidGetTappedNotification, object: self)

I'm observing the notification in another instance like so:

NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("colorDidGetTapped:"), name: ColorDidGetTappedNotification, object: nil)
....
func colorDidGetTapped(notification: NSNotification) {
    println("Notification recieved")
}

But I get an unrecognized selector exception:

UPDATE 1

*** NSForwarding: warning: object 0x7d564490 of class '_D.GameModel' does not implement methodSignatureForSelector: -- trouble ahead
Unrecognized selector -[_D.GameModel colorDidGetTapped:]
Youssef Moawad
  • 2,846
  • 5
  • 28
  • 50

2 Answers2

5

Check GameModel is NSObject's subclass

class GameModel: NSObject {

}
Huynh Inc
  • 2,010
  • 1
  • 25
  • 42
0

Try to observe the Notification using this method: addObserverForName(_:object:queue:usingBlock:). Instead of a selector you pass a block

Yariv Nissim
  • 13,273
  • 1
  • 38
  • 44