I used this tutorial How do you add an in-app purchase to an iOS application? for SKPayment (verbatim) and I am having trouble linking the purchase buttons on my storyboard to my code.
- (IBAction)purchase:(SKProduct *)product{
I keep getting the following error.
[UIButton productIdentifier]: unrecognized selector sent to instance 0x7ffa08cfbe90
I understand that the tutorial uses a xib file but I am using a storyboard file for my game to link the buttons. Can somebody please tell me how I would link my purchase button in my storyboard to the
- (IBAction)purchase:(SKProduct *)product{
code without getting an unrecognized selector error?
It's because
IBAction
expects asender
as its first parameter. And when it's "linked" to aUIButton
, thatUIButton
is thesender
(it's automatically sent). That why you get the error,UIButton
doesn't know the selectorproductIdentifier
.If you look carefully to the answer your linked on SO, the methods linked to IB aren't this one. This one is called with
[self purchase:someSKProduct]
, that's why it's not causing the crash on his/her code.Well, I haven't played with StoreKitFramework, but it seems that this method shouldn't be an IBAction (either here on on the answer, it's confusing, proof: your current issue.). It should be just
-(void)purchase:(SKProduct *)product
.