4

アップデートを送信したばかりの iOS アプリがあります。アプリの開発バージョン (シミュレーターと私の 4S) はクラッシュせず、問題なく動作します。アプリは今日、IAP と同様に承認されましたが、今朝、iAP が「購入許可」されていないことに気付きました。購入のためにクリアしましたが、アプリはまだクラッシュします。iPhoneが与えるエラー(アプリストアバージョンを実行している)は、エラーを与えます:

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

これが発生するコードは次のとおりです。

- (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];
    }
}

これは、利用可能な製品のリストを要求しているときに発生します。これは明らかに製品をシミュレーターで返しますが、アプリでは返しません。これに対するセーフガードを追加したばかりですが、App Store に再度提出する必要があります。

App Store バージョンで iAP が表示されない理由を知っている人はいますか? Apple のサーバーにアクセスするには、「売却済み」オプションを待つ必要がありますか? ありがとう!

4

1 に答える 1

0

明らかにmyProduct配列は空です。なぜこれが発生するのかは別の質問ですがobjectAtIndex、要求されたインデックスが存在することを確認せずに呼び出すことは絶対にしないでください。

if ([myProduct count] > 0)
    noAdProduct = [myProduct objectAtIndex:0];
else
   // Deal with the situation when the array is empty.
于 2012-11-21T23:51:46.300 に答える