I'm having issues trying to pass back userInfo via postNotification in Swift. What's strange is the code only breaks when I try to use userInfo -- if I post a notification with no data to a selector with no parameters, everything works. But when I try to pass back userInfo, I get a "unrecognized selector sent to instance" error. So something's wrong with my selector signature in my ViewController, but I can't figure out what.
Here is the code that breaks:
In my table view
let data = ["selection": selectedOption]
dismissViewControllerAnimated(true, completion: {NSNotificationCenter.defaultCenter().postNotificationName(wordsetPickedNotification, object: self, userInfo: data)})
In my view controller:
NSNotificationCenter.defaultCenter().addObserver(self, selector: "wordsetPicked", name: wordsetPickedNotification, object: nil)
...
func wordsetPicked(n:NSNotification) {
//do stuff
}
Change selector: "wordsetPicked"
to selector: "wordsetPicked:"
.