简体   繁体   English

在App Purchase Crashes App中

[英]In App Purchase Crashes App

I have an iOS App that I just submitted an update for. 我有一个iOS应用程序,我刚刚提交了更新。 The development version of the app (simulator and my 4S) never crashed and it works just fine. 应用程序的开发版本(模拟器和我的4S)从未崩溃,它工作得很好。 The app got approved today as well as the IAP, but I realized this morning that the iAP was not "cleared for purchase". 该应用程序今天获得批准以及IAP,但我今天早上意识到iAP并未“清除购买”。 I just cleared it for purchase, but the app still crashes. 我刚刚购买它,但应用程序仍然崩溃。 The error the iPhone gives (running the app store version) gives the error: iPhone提供的错误(运行应用程序商店版本)给出错误:

<Error>: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'

Here is the code where that happens: 以下是发生这种情况的代码:

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:
(SKProductsResponse *)response
{
    NSArray *myProduct = response.products;
    //this line is where the error occurs
    noAdProduct = [myProduct objectAtIndex:0];
    if (![[[NSUserDefaults standardUserDefaults] objectForKey:@"the id here"] boolValue]) {
        adCell.detailTextLabel.text = [NSString stringWithFormat:@"$%@", noAdProduct.price];
        adCell.userInteractionEnabled = YES;
        adCell.accessoryType = UITableViewCellAccessoryNone;
        adCell.accessoryView = nil;
        [self.tableView reloadData];
    }
}

This happens while requesting a list of available products, which obviously returns the product in the simulator but not in the app. 在请求可用产品列表时会发生这种情况,这显然会在模拟器中返回产品,但不会在应用程序中返回。 I just added a safeguard against this but I will need to submit it to the App Store again. 我刚刚添加了一个防范措施,但我需要再次将其提交到App Store。

Does anyone know why the iAP is not showing up for the App Store version? 有谁知道为什么iAP没有出现在App Store版本中? Do I need to wait for the "cleared for sale" option to go to Apple's servers? 我是否需要等待“清算销售”选项才能转到Apple的服务器? Thanks! 谢谢!

Obviously myProduct array is empty. 显然myProduct数组是空的。 Why this happens is another question, but you should never call objectAtIndex without making sure the requested index exists. 为什么会发生这是另一个问题,但是你不应该在不确保所请求的索引存在的情况下调用objectAtIndex

if ([myProduct count] > 0)
    noAdProduct = [myProduct objectAtIndex:0];
else
   // Deal with the situation when the array is empty.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM