[英]getNode:withName: method of soap is called more than 2 million times when parsing some big xml web service
[英]method called more times
這個問題很長,但很容易理解,請花點時間:)
幾周前,我為我的應用創建了一個商店頁面。 我是初次接觸應用內購買商品,並獲得了一些網上代碼。 這是為1個對象制作的,因此我決定根據自己的需要編輯代碼。 一次購買該應用的專業版,然后進行3次購買3種不同金額的硬幣。
當我購買硬幣時,效果很好,唯一的問題是第二次購買時它將添加我購買的硬幣數量的2倍,第三次它將添加我所購買的硬幣數量的3倍,等等。我希望有人可以看看在我的代碼,告訴我怎么了。 對於本主題,我將代碼縮小了一點,並且不會顯示所有購買內容。
//the 100 coins button
-(IBAction)savedata100:(id)sender {
askToPurchase100Munten = [[UIAlertView alloc]
initWithTitle:@"100 Munten"
message:@"Ga verder om 100 Munten te kopen."
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Verder", @"Cancel", nil];
askToPurchase100Munten.delegate = self;
[askToPurchase100Munten show];
[askToPurchase100Munten release];
//下一步
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
else if (alertView==askToPurchase100Munten) {
if (buttonIndex==0) {
// user tapped YES, but we need to check if IAP is enabled or not.
if ([SKPaymentQueue canMakePayments]) {
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"100Munten"]];
Temp = 2;
request.delegate = self;
[request start];
} else {
UIAlertView *tmp = [[UIAlertView alloc]
initWithTitle:@"Prohibited"
message:@"Parental Control is enabled, cannot make a purchase!"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Ok", nil];
[tmp show];
[tmp release];
}
}
}
//下一步
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse: (SKProductsResponse *)response
{
statusLabel.text = @"";
int count = [response.products count];
}
if (Temp == 2){
if (count>0) {
SKProduct *selectedProduct = [response.products objectAtIndex:0];
SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];
} else {
UIAlertView *tmp = [[UIAlertView alloc]
initWithTitle:@"Not Available"
message:@"No products to purchase"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Ok", nil];
[tmp show];
[tmp release];
}
}
//這是我每次執行的最后一步,即被調用的次數越來越多(uiView也會彈出多次)
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
// show wait view here
statusLabel.text = @"Verwerken...";
break;
case SKPaymentTransactionStatePurchased:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
// remove wait view and unlock feature 2
statusLabel.text = @"Klaar!";
if (Temp == 2){
//ADD COINS WHEN PURCHASES IS COMPLETE
int coinsToAdd = 100;
int currentCoins = [[NSUserDefaults standardUserDefaults] integerForKey:@"savedstring"];
int savestring =
currentCoins + coinsToAdd;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setInteger:savestring forKey:@"savedstring"]; [defaults synchronize];
[label111 setText:[NSString stringWithFormat:@"Munten: %i",[self getCoins]]];
//ALERTVIEW TO SHOW YOU PURCHASED COINS
UIAlertView *tmp2 = [[UIAlertView alloc]
initWithTitle:@"Voltooid"
message:@"Je hebt 100 Munten Gekocht"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Ok", nil];
[tmp2 show];
[tmp2 release];
感謝您的閱讀,希望有人可以幫助我:)
進行交易后,應將transaction.transactionState設置為SKPaymentTransactionStatePurchased,否則,下次將重復該交易。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.