gpt4 book ai didi

ios - 在 UIView 之间切换时 SKPaymentQueue Dealloc 问题

转载 作者:行者123 更新时间:2023-11-28 20:23:00 25 4
gpt4 key购买 nike

我在应用程序购买代码中有以下内容。

- (IBAction)purchaseProduct:(id)sender
{
SKProduct *thisProduct = [productDetailsList objectAtIndex:[sender tag]];

if ([thisProduct.productIdentifier isEqualToString:@"demo"]) {
SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"demo"];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
}

购买屏幕是由导航 Controller 控制的独立 uiview。我第一次加载屏幕并进行购买时一切正常。但是,如果我加载屏幕,离开然后返回并进行购买,我会收到以下错误:

*** -[FilterPurchase respondsToSelector:]: message sent to deallocated instance 0x1fd92ca0

在执行断点检查后,错误似乎发生在这一行附近:

[[SKPaymentQueue defaultQueue] addPayment:payment];

有人能看到这里的问题吗?我正在使用 ARC,所以我有点不确定如何解决这个问题。

谢谢

更新

如果我也点击“恢复”按钮,同样的事情会发生

- (IBAction)restorePurchases:(id)sender
{
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}

最佳答案

根据文档:

An application should always have at least one observer of the payment queue before adding payment requests.

听起来您的 SKPaymentTransactionObserver 可能会与您的 IAP uiview 一起被释放。

关于ios - 在 UIView 之间切换时 SKPaymentQueue Dealloc 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15225909/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com