title: Inapppurchase SKProductsRequest Crash my application in ios5
body: <p>my store kit class crash for SKProductsRequest start i am not experienced inapppurchase concept my class working perfectly in iOS 4.3 sdk not iOS 5 sdk. i am not getting error on console and my application crashed before after SKProductsRequest start please can any one help me how to fix this issue here's my code:</p>
  
  <pre><code>#import "StorePurchase.h"
  
  @implementation StorePurchase
  @synthesize request = _request;
  
  - (void)loadStore {
  
      if ([SKPaymentQueue canMakePayments]) {
          NSLog(@"Parental-controls are disabled");
          self.request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"com.mycompany.app"]];
          self.request.delegate = self;
          [self.request start];
      }
      else {
          NSLog(@"Parental-controls are enabled");
      }
  
  }
  static bool hasAddObserver=NO;
  
  - (void)purchase {
      if (!hasAddObserver) {//flag to fix this bug
          /*=====================================*/
          [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
          hasAddObserver=YES;
      }
      SKMutablePayment *payment = [[SKMutablePayment alloc] init] ;
      payment.productIdentifier = @"com.mycompany.app";
      payment.quantity = 1;
      [[SKPaymentQueue defaultQueue] addPayment:payment];
  }
  
  - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
      SKProduct *validProduct = nil;
      int count = [response.products count];
      if (count &gt; 0) 
      {
          validProduct = [response.products objectAtIndex:0];
          NSLog(@"Products found,Magic Box!");
          [[NSNotificationCenter defaultCenter] postNotificationName:kProductsLoadedNotification object:@"Product Found..!"];
  
      } else if (!validProduct) 
      {
          NSLog(@"No products available");
          [[NSNotificationCenter defaultCenter] postNotificationName:kProductsLoadedNotification object:@"Product Not Found..!"];
  
      } 
  }
  
  - (void)provideContent:(NSString *)productIdentifier {
  
      NSLog(@"Toggling flag for: %@", productIdentifier);
      [[NSUserDefaults standardUserDefaults] setBool:TRUE forKey:productIdentifier];
      [[NSUserDefaults standardUserDefaults] synchronize];
      //[_purchasedProducts addObject:productIdentifier];
  
      [[NSNotificationCenter defaultCenter] postNotificationName:kProductPurchasedNotification object:productIdentifier];
  
  }
  
  - (void)completeTransaction:(SKPaymentTransaction *)transaction {
  
      NSLog(@"completeTransaction...");
  
      //[self recordTransaction: transaction];
      [self provideContent: transaction.payment.productIdentifier];
      [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
  
  }
  
  - (void)restoreTransaction:(SKPaymentTransaction *)transaction {
  
      NSLog(@"restoreTransaction...");
  
      //[self recordTransaction: transaction];
      [self provideContent: transaction.originalTransaction.payment.productIdentifier];
      [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
  
  }
  
  - (void)failedTransaction:(SKPaymentTransaction *)transaction {
  
      if (transaction.error.code != SKErrorPaymentCancelled)
      {
          NSLog(@"Transaction error: %@", transaction.error.localizedDescription);
      }
  
      [[NSNotificationCenter defaultCenter] postNotificationName:kProductPurchaseFailedNotification object:transaction];
      [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
  }
  
  - (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error
  {
      NSLog(@"&lt;&gt;&lt;Canceled!&gt;&lt;&gt;");
      [[NSNotificationCenter defaultCenter] postNotificationName:kProductPurchaseCanceledNotification object:error];
  
  
  }
  
  - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
  
  
      for (SKPaymentTransaction *transaction in transactions) {
  
          switch (transaction.transactionState) {
  
              case SKPaymentTransactionStatePurchasing:
                  // [self completeTransaction:transaction];
                  break;
  
              case SKPaymentTransactionStatePurchased:
                  NSLog(@"Purchased");
                  [self completeTransaction:transaction];
                  //[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
  
                  break;
  
              case SKPaymentTransactionStateRestored:
                  //[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                  NSLog(@"Restored");
                  [self restoreTransaction:transaction];
  
                  break;
  
              case SKPaymentTransactionStateFailed:
                  if (transaction.error.code != SKErrorPaymentCancelled) {
                      NSLog(@"An error encounterd");
                  }
                  else {
                      NSLog(@"Cancelled!");
                  }
                  //[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
  
                  [self failedTransaction:transaction];
  
                  break;
  
          }
  
      }
  
  
  }
  </code></pre>
  
  <p>i am call the <code>loadStore</code> method after getting the error</p>
  
  <p>SKProductsRequest doesn't call the - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response method before crash my app!</p>
  
  <p>What's Wrong in my code how to fix!
  Thanks in Advance!</p>