执行应用程式内购买IOS,但是当我在按钮轻敲我得到异常作为fatel错误:数组索引超出范围

问题描述:

  MCIAPHelper.sharedInstance.buyProduct(self.fetchedProducts[0]) . // getting exception in this line 
     if let sender = sender as? UIButton { 
      sender.userInteractionEnabled = false 
      self.buttonToRestore = sender 
     } 
    } 

我创建按钮购买,当我敲击按钮例外快到了,能有人建议我,我做错了什么。执行应用程式内购买IOS,但是当我在按钮轻敲我得到异常作为fatel错误:数组索引超出范围

enter image description here

+4

的错误信息是很清楚的:你索引的东西,在它没有任何项目。为什么?不知道基于这个代码。调试时间 –

确保您在fetchedProducts添加的项目也尝试检查之前使用它:

if fetchedProducts.count > 0 { 
    MCIAPHelper.sharedInstance.buyProduct(self.fetchedProducts[0]) 
    if let sender = sender as? UIButton { 
     sender.userInteractionEnabled = false 
     self.buttonToRestore = sender 
    } 
}