簡體   English   中英

在App Purchase Crashes App中

[英]In App Purchase Crashes App

我有一個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。

有誰知道為什么iAP沒有出現在App Store版本中? 我是否需要等待“清算銷售”選項才能轉到Apple的服務器? 謝謝!

顯然myProduct數組是空的。 為什么會發生這是另一個問題,但是你不應該在不確保所請求的索引存在的情況下調用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