When buying an application does not work

I use this tutorial http://www.raywenderlich.com/2797/introduction-to-in-app-purchases to create purchases in my application.

This code may or may not work from time to time. I know this sounds funny, but it's my problem.

For example: The first application to start (all elements are loaded and displayed in the table, and I can purchase any of them), but the next time (for example, the second start) I get an error message in this line:

SKProduct *product = [[InAppRageIAPHelper sharedHelper].products objectAtIndex:0]; 

Error

Application termination due to uncaught exception "NSRangeException" index 0 outside for empty array

0
source share
3 answers

reset .

0

, :

if ([[InAppRageIAPHelper sharedHelper].products count] >0)
{
   SKProduct *product = [[InAppRageIAPHelper sharedHelper].products objectAtIndex:0];
   //product processing goes here
}
else
{
   NSLog (@"Warning: no products returned");
}
+2

use this code when you use the payment method ..... as the payment button is pressed

NSLog(@"Products - %@",[IAPClockDietHelper sharedHelper].products);

You find that when you start the application for the first time, then you have the product valve ... and when you use the application the Second time, then the products have the value NULL .... So your application is crashing ... check. .

+1
source

All Articles