我正在使用以下代码:
但错误是:开关案例在案例SKPaymentTransactionStateRestored的保护范围内:也案例SKPaymentTransactionStateFailed:和
默认值:
有人解决这个问题吗?
先感谢您。
-(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;
}
}
}