title: how to Apply upgrades (inappPurchage )for buttons?
body: <p>I have done a photoEditorApp, which is in AppStore. Now i want to apply InApppurchage for some Buttons only. In my App overlays button is there when we click that button we are getting 7 buttons in which 3 buttons for free remaining 4 buttons for purchase .for that i have written code like this .but its not working don't know where i did mistake so please anyone suggest how to do UIScrollView *scrollView;</p>
  
  <pre><code>-(void)createScrolling2
  {
  previousButtonTag=1000;
  if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) {
  scrollView=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 4, self.overlaysView.frame.size.width, 106)];
  int x =0.5;
  for (int i = 0; i&lt;8; i++) {
  UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  button.frame=CGRectMake(x, 0, 100, 100);
  button.layer.borderWidth=0.5;
  button.titleLabel.font=[UIFont boldSystemFontOfSize:12];
  button.titleLabel.textAlignment = NSTextAlignmentCenter;
  button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
  button.layer.borderColor=[[UIColor lightGrayColor]CGColor];
  button.tag = i;
  
  if (subButtonTag == 101) {
  [button setBackgroundImage:[self.fireworksArray objectAtIndex:i] forState:UIControlStateNormal];
  
  }
  else if (subButtonTag == 102){
  [button setBackgroundImage:[self.flowersArray objectAtIndex:i] forState:UIControlStateNormal];
  }
  else if (subButtonTag == 103){
  [button setBackgroundImage:[self.loveArray objectAtIndex:i] forState:UIControlStateNormal];
  }
  else if (subButtonTag == 104){
  [button setBackgroundImage:[self.rainbowArray objectAtIndex:i] forState:UIControlStateNormal];
  } 
  int previousButtonTag;
  
  -(void)OverLayMethod:(UIButton*)sender{
  
  UIButton *selectButton = (UIButton*)sender;
  NSLog(@"hi %d",sender.tag);
  previousButtonTag=selectButton.tag;
  NSLog(@"hi %d",sender.tag);
  UIImage *selectImage;
  
  if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone){
  if (subButtonTag == 101) {
  selectImage = [self.fireworksArray objectAtIndex:sender.tag];
  NSLog(@"selectImage = %@",selectImage);
  self.overlayImgView.image = selectImage;
  
  }
  else if (subButtonTag == 102){
  
  selectImage = [self.flowersArray objectAtIndex:sender.tag];
  NSLog(@"selectImage = %@",selectImage);
  self.overlayImgView.image = selectImage;
  
  }
  
  else if (subButtonTag == 103){
  
  selectImage = [self.loveArray objectAtIndex:sender.tag];
  NSLog(@"selectImage = %@",selectImage);
  self.overlayImgView.image = selectImage;
  
  }
  else if (subButtonTag == 104){
  
  selectImage = [self.rainbowArray objectAtIndex:sender.tag];
  NSLog(@"selectImage = %@",selectImage);
  self.overlayImgView.image = selectImage;
  
  }
  - (IBAction)buyPackClicked:(id)sender
  {
  if (![demoPurchase restorePurchase])
  {
  UIAlertView *settingsAlert = [[UIAlertView alloc] initWithTitle:@"Allow Purchases" message:@"You must first enable In-App Purchase in your iOS Settings before restoring a previous purchase." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
  [settingsAlert show];
  
  }
  }
  - (IBAction)restorePreviousClicked:(id)sender
  {
    if (demoPurchase.validProduct != nil)
  {
  if (![demoPurchase purchaseProduct:demoPurchase.validProduct])
  {
  UIAlertView *settingsAlert = [[UIAlertView alloc] initWithTitle:@"Allow Purchases" message:@"You must first enable In-App Purchase in your iOS Settings before making this purchase." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
  [settingsAlert show];
  
  }
  }
  }
  -(void) requestedProduct:(EBPurchase*)ebp identifier:(NSString*)productId name:(NSString*)productName price:(NSString*)productPrice description:(NSString*)productDescription
  {
  SKProduct *product = ebp.validProduct; // epb is the EBPurchase object
  NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
  [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
  [numberFormatter setLocale:product.priceLocale];
  NSString *formattedPrice = [numberFormatter stringFromNumber:product.price];
  NSLog(@"ViewController requestedProduct %@",productPrice);
  if (productPrice != nil)
  {
  [buyPack setTitle:[@"Buy Pack item " stringByAppendingString:productPrice] forState:UIControlStateNormal];
  buyPack.enabled = YES; // Enable buy button.
  
  } 
  else {
  buyPack.enabled = NO; // Ensure buy button stays disabled.
  [buyPack setTitle:@"Buy Pack item" forState:UIControlStateNormal];
  
  UIAlertView *unavailAlert = [[UIAlertView alloc] initWithTitle:@"Not Available" message:@"This In-App Purchase item is not available in the App Store at this time. Please try again later." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
  [unavailAlert show];
  
  }
  
  }
  
  -(void) successfulPurchase:(EBPurchase*)ebp restored:(bool)isRestore identifier:(NSString*)productId receipt:(NSData*)transactionReceipt
  {
  NSLog(@"ViewController successfulPurchase");
  
  if (!isPurchased)
  {
  isPurchased = YES;
  NSString *alertMessage;
  
  if (isRestore) {
  alertMessage = @"Your purchase was restored and the Game Levels Pack is now unlocked for your enjoyment!";
  
   } else {
   alertMessage = @"Your purchase was successful and the Game Levels Pack is now unlocked for your enjoyment!";
   }
  
   UIAlertView *updatedAlert = [[UIAlertView alloc] initWithTitle:@"Thank You!" message:alertMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
   [updatedAlert show];
  
   }
   }
  
   -(void) failedPurchase:(EBPurchase*)ebp error:(NSInteger)errorCode message:(NSString*)errorMessage
   {
   NSLog(@"ViewController failedPurchase");
   UIAlertView *failedAlert = [[UIAlertView alloc] initWithTitle:@"Purchase Stopped" message:@"Either you cancelled the request or Apple reported a transaction error. Please try again later, or contact the app's customer support for assistance." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
   [failedAlert show];
  
   }
  
   -(void) incompleteRestore:(EBPurchase*)ebp
   {
   NSLog(@"ViewController incompleteRestore");
   UIAlertView *restoreAlert = [[UIAlertView alloc] initWithTitle:@"Restore Issue" message:@"A prior purchase transaction could not be found. To restore the purchased product, tap the Buy button. Paid customers will NOT be charged again, but the purchase will be restored." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
  [restoreAlert show];
  
  
  }
  
  -(void) failedRestore:(EBPurchase*)ebp error:(NSInteger)errorCode message:(NSString*)errorMessage
  {
  NSLog(@"ViewController failedRestore");
  UIAlertView *failedAlert = [[UIAlertView alloc] initWithTitle:@"Restore Stopped" message:@"Either you cancelled the request or your prior purchase could not be restored. Please try again later, or contact the app's customer support for assistance." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
  [failedAlert show];
  
  }
  </code></pre>
  
  <p>Here when I want to click any button in that 4 buttons getting alert for buy diaplying cost.</p>