Advertisement
Guest User

Untitled

a guest
Nov 12th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -(void)purchaseSucceeded:(NSNotification*)notification {
  2.     NSString *productIdentifier = (NSString*)notification.object;
  3.     [defaults setBool:YES forKey:productIdentifier];
  4.     [defaults setBool:YES forKey:@"ProductPurchased"];
  5.     [defaults synchronize];
  6.     if ([productIdentifier containsString:@"Pro"]){
  7.         [_buyButton setTitle:@"PURCHASED" forState:UIControlStateNormal];
  8.         for (NSDictionary *dic in dataArray) {
  9.             [defaults setBool:YES forKey:[dic valueForKey:@"identifier"]];
  10.         }
  11.     }
  12.     BOOL isPro = NO;
  13.     int countItem = 0;
  14.     for (NSDictionary *dic in dataArray) {
  15.         NSString *tmpIdentifier = [dic valueForKey:@"identifier"];
  16.         if([defaults boolForKey:tmpIdentifier]) {
  17.             countItem++;
  18.         }else{
  19.             break;
  20.         }
  21.     }
  22.     if(countItem == dataArray.count)
  23.         isPro = YES;
  24.    
  25.     if (isPro) {
  26.         NSString *filePath  = [[NSBundle mainBundle] pathForResource: @"InAPP" ofType:@"plist"];
  27.         NSDictionary *uiInfoDic = [NSDictionary dictionaryWithContentsOfFile:filePath];
  28.         NSString *key = [uiInfoDic valueForKey:@"identifierPro"];
  29.         [defaults setBool:YES forKey:key];
  30.         [_buyButton setTitle:@"PURCHASED" forState:UIControlStateNormal];
  31.     }
  32.    
  33.     [[NSNotificationCenter defaultCenter] postNotificationName:@"Reload_Collection_View" object:productIdentifier];
  34.    
  35.     [_tableView reloadData];
  36.     [hud hideAnimated:YES];
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement