I'm using this IAP implementation guide and when a purchase is final, it posts a notification using this code:
NotificationCenter.default.post(name: NSNotification.Name(rawValue: IAPHelper.IAPHelperPurchaseNotification), object: identifier)
The implementation doesn't include observer code, so I added the below into the function that runs when the "Buy" button is pressed:
var functionToRun = #selector(MyViewController.runAfterBoughtFunc)
NotificationCenter.default.addObserver(self, selector: functionToRun, name: NSNotification.Name(rawValue: IAPHelper.IAPHelperPurchaseNotification), object:nil)
My problem is that when the NotificationCenter.default.post(...) code gets called I get this error:
...runAfterBoughtFuncWithNotif:]: unrecognized selector sent to instance 0x100f12fc0
(lldb)
Notes
- If I comment-out the observer code, I no longer get an error.
- If you look at the IAP Guide I'm using, in the comments another user had the same problem, so this is not isolated to only my code
Anyone know how to fix it?