在应用购买中执行时出错

时间:2013-08-22 09:45:13

标签: ios in-app-purchase

我正在从http://www.raywenderlich.com/21081/introduction-to-in-app-purchases-in-ios-6-tutorial购买应用。我尝试在reload方法之外打印产品数组时出错。 我想在menuitem操作中使用此产品数组。它还显示了数组的正确大小,但是当我尝试在该数组中打印或使用该产品时,它会给我一个错误。

-(id) init
{
  if( (self=[super init]))
  {
    isTouchEnabled=YES;
    startY=120;
    startX=90;

    CCMenuItemImage *menuitem1 = [CCMenuItemImage itemFromNormalImage:@"100.png"                                      selectedImage:@"100.png" target:self selector:@selector(buy100C:)];
    CCMenuItemImage *menuitem2 = [CCMenuItemImage itemFromNormalImage:@"220.png"   selectedImage:@"220.png" target:self selector:@selector(buy220C:)];
    CCMenuItemImage *menuitem3 = [CCMenuItemImage itemFromNormalImage:@"350.png" selectedImage:@"350.png" target:self selector:@selector(buy350C:)];
    CCMenuItemImage *menuitem4 = [CCMenuItemImage itemFromNormalImage:@"500.png" selectedImage:@"500.png" target:self selector:@selector(buy500C:)];
    CCMenuItemImage *menuitem5 = [CCMenuItemImage itemFromNormalImage:@"1800.png" selectedImage:@"1800.png" target:self selector:@selector(buy1800C:)];
    CCMenuItemImage *menuitem6 = [CCMenuItemImage itemFromNormalImage:@"3000.png" selectedImage:@"3000.png" target:self selector:@selector(buy3000C : )];
    CCMenuItemImage *menuitem7 = [CCMenuItemImage itemFromNormalImage:@"back2.png" selectedImage:@"back2.png" target:self selector:@selector(back)];
    CCMenu *menu = [CCMenu menuWithItems:menuitem1,menuitem2,menuitem3,menuitem4,menuitem5,menuitem6,menuitem7, nil];
    [menu alignItemsVerticallyWithPadding:2];
    menu.position=ccp(startX, startY);
    menu.scale=.55;
    [self addChild:menu];
    [RageIAPHelper sharedInstance];
    [self reload];
}

return self;

}
-(void)reload
{
[[RageIAPHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success,   NSArray *products) {
    if (success) {

            _products = products;

        NSLog(@"produts==%d",[_products count]);
         NSLog(@"product===%@",_products);
        for (SKProduct * skProduct in _products) {
            NSLog(@"Found product: %@ %@ %0.2f",
                  skProduct.productIdentifier,
                  skProduct.localizedTitle,
                  skProduct.price.floatValue);
        }

    }
   }];
}
-(void)buy100C:(id) sender
{

 NSLog(@"hisize=======%d",[_products count]);
 if([_products count] >=8){
  NSLog(@"product===%@",_products);//this line is giving error and app stop.
}
}

这里的buy100C方法我没有从阵列中获得产品。

0 个答案:

没有答案