Ios6 ios 6 InApp购买SKPaymentTransaction不工作方法

Ios6 ios 6 InApp购买SKPaymentTransaction不工作方法,ios6,in-app-purchase,in-app-billing,storekit,xcode4.6,Ios6,In App Purchase,In App Billing,Storekit,Xcode4.6,我正在使用以下代码: 但错误是:开关案例在案例SKPaymentTransactionStateRestored的受保护范围内: 而且 案例SKPaymentTransactionState失败: 和 默认值: 有人能解决这个问题吗 先谢谢你 -(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { for (SKPaymentTransaction *transa

我正在使用以下代码:

但错误是:开关案例在案例SKPaymentTransactionStateRestored的受保护范围内: 而且 案例SKPaymentTransactionState失败: 和 默认值:

有人能解决这个问题吗

先谢谢你

-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {

    for (SKPaymentTransaction *transaction in transactions)
 {
        switch (transaction.transactionState)

        {
            case SKPaymentTransactionStatePurchasing:
                                 //[self completeTransaction:transaction];
                // show wait view here
                statusLabel.text = @"Processing...";
                break;

            case SKPaymentTransactionStatePurchased:

                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                // remove wait view and unlock feature 2
                statusLabel.text = @"Done!";
                UIAlertView *tmp = [[UIAlertView alloc]
                                    initWithTitle:@"Complete"
                                    message:@"You have unlocked Feature 2!"
                                    delegate:self
                                    cancelButtonTitle:nil
                                    otherButtonTitles:@"Ok", nil];
                [tmp show];



                NSError *error = nil;
                [SFHFKeychainUtils storeUsername:@"IAPNoob01" andPassword:@"whatever" forServiceName:kStoredData updateExisting:YES error:&error];

                // apply purchase action  - hide lock overlay and
                [feature2Btn setBackgroundImage:nil forState:UIControlStateNormal];

                // do other thing to enable the features

                break;

   case SKPaymentTransactionStateRestored: //ERROR:- Switch case is in protected scope

                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

                // remove wait view here
                statusLabel.text = @"";

                break;

 case SKPaymentTransactionStateFailed: //ERROR:- Switch case is in protected scope

                if (transaction.error.code != SKErrorPaymentCancelled)
            //    [self failedTransaction:transaction];
                {
                    NSLog(@"Error payment cancelled");
                }
                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                // remove wait view here
                statusLabel.text = @"Purchase Error!";
                break;

          default:  //ERROR:- Switch case is in protected scope

                break;
        }
    }
}

你应该用一个{和}把这个箱子围起来

例如:

    switch (transaction.transactionState)
    {
        case SKPaymentTransactionStatePurchasing:
            {
                //[self completeTransaction:transaction];
                // show wait view here
                statusLabel.text = @"Processing...";
                break;
            }
        case SKPaymentTransactionStateFailed:
            {
                // another case contents
                break;
            }
    }