I have a UITableView
set up with different in app purchases. Each option takes you to a view controller which also has the delegate and what not to do the in app purchases. A plist file is change to determine which option in the table view was selected. This all works fine. I put in NSLogs to make sure the variable was getting set. However when i click buy, it only works half the time and the other half i get
EXC_BAD_ACCESS
on the line:
[[SKPaymentQueue defaultQueue] addPayment:payment];
Everything is set up right as far as the in app purchases go because it used to work before i switched to this way of doing it. I think it may have something to do with calling the productsRequest because i set up NSLog
in the didReceiveResponse
delegate and it receive the response much quicker after the first time. Im stuck. The ones that dont work are always random, no rhyme or reason. Any help is appreciated.
I was having this problem and found that the issue was that I was releasing the transaction observer I'd added to the default SKPaymentQueue. Apparently SKPaymentQueue does not retain its observers, probably to prevent a retain cycle.
So, specifically, I changed this code:
- (void) setupAppStoreObserver {
AppStoreObserver *appStoreObserver = [[AppStoreObserver alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:appStoreObserver];
[appStoreObserver release]; // This is the problem
}
To this:
- (void) setupAppStoreObserver {
AppStoreObserver *appStoreObserver = [[AppStoreObserver alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:appStoreObserver];
// Note, we don't release the appStoreObserver because it is not
// actually retained by SKPaymentQueue (probably to prevent retain cycles)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With