SKProduct 属性抛出 exc_bad_access

发布于 2024-10-10 06:36:54 字数 699 浏览 0 评论 0原文

我正在我的应用程序中实现应用程序内购买。我在 itunes 上创建了一个产品,并在代码中成功创建了产品请求功能。产品退货。问题是我无法访问产品的任何属性(localizedTitle、价格等)。它总是抛出 exc_bad_access。这是我的代码:

NSMutableArray *myProduct = [[NSMutableArray alloc] init];
[myProduct addObjectsFromArray:response.products];

 if(myProduct != nil && [myProduct count] > 0)
 {
    SKProduct *subscriptionProduct = [myProduct objectAtIndex:0];
    if(subscriptionProduct != nil)
    {
       if(subscriptionProduct.localizedTitle != nil) 
            NSLog("%@",subscriptionProduct.localizedTitle); /***EXC_BAD_ACCESS** */
    }
 }
 [request autorelease];

我将 NSZombieEnabled 设置为 YES,但仍然没有对 exc_bad_access 的解释。

如果有人有答案,我会很高兴。 提前致谢。

I'm implementing in app purchase in my app. I created a product at itunes and also product requesting functions in code successfully. the product returns. the problem is that i cannot access any of the attributes of the prouct (localizedTitle, price etc.). It allways throws exc_bad_access. here's my code:

NSMutableArray *myProduct = [[NSMutableArray alloc] init];
[myProduct addObjectsFromArray:response.products];

 if(myProduct != nil && [myProduct count] > 0)
 {
    SKProduct *subscriptionProduct = [myProduct objectAtIndex:0];
    if(subscriptionProduct != nil)
    {
       if(subscriptionProduct.localizedTitle != nil) 
            NSLog("%@",subscriptionProduct.localizedTitle); /***EXC_BAD_ACCESS** */
    }
 }
 [request autorelease];

I set NSZombieEnabled YES, but still no explanation for exc_bad_access.

I'll be glad if someone has an answer.
Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

够钟 2024-10-17 06:36:54

您忘记在 NSLog 格式字符串之前添加 @ 符号:

NSLog(@"%@",subscriptionProduct.localizedTitle); /***EXC_BAD_ACCESS** */

You've forgotten to put an @ symbol before your NSLog format string:

NSLog(@"%@",subscriptionProduct.localizedTitle); /***EXC_BAD_ACCESS** */
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文