ios - SKPaymentQueue addPayment is throwing an exception -


i have configured ios application's in app purchases in apple's portal, asking products using skproductsrequest , correctly receiving , storing them in nsmutabledictionary.

-(void)productsrequest:(skproductsrequest *)request didreceiveresponse:(skproductsresponse*)response {     nslog(@"%@", @"appstore: accepted");     (skproduct * s in response.products) {         nslog(@"    [%@]", s.productidentifier);     }      [productsbyid removeallobjects];      (skproduct * product in response.products) {         [productsbyid setobject:product forkey:product.productidentifier];     }      [request release]; } 

however, when trying make purchase, addpayment line throws 'nsinvalidargumentexception', reason: '*** setobjectforkey: key cannot nil'

-(void)purchase:(nsstring *)productid {     skproduct *selectedproduct = [productsbyid objectforkey:productid];     skmutablepayment *payment = [skmutablepayment paymentwithproduct: selectedproduct];     payment.quantity = 1;      [[skpaymentqueue defaultqueue] addtransactionobserver: self];     [[skpaymentqueue defaultqueue] addpayment: payment]; //<- line throws exception } 

i have checked productid valid product , payment.quantity > 0, apple's documentation says. have tried both in simulator , in ipad same results. in advance help.

i'm pretty sure you're not allocating productsbyid dictionary.

put self.productsbyid = [@{} mutablecopy]; -viewdidload: method


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -