Advertisement
ilis

createSectionsWithTheirRows

Jun 26th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -(void)createSectionsWithTheirRows{
  2.  
  3.     NSURL *aURL=[NSURL URLWithString:[NSString stringWithString:@"http://192.168.69.106/ipad/button.php?key=181abc88e57c37a42769"]];
  4.    
  5.     NSData *data2=[NSData dataWithContentsOfURL:aURL];
  6.     id result2=[NSJSONSerialization JSONObjectWithData:data2 options:NSJSONReadingMutableContainers error:nil];
  7.     NSDictionary *template=[result2 objectForKey: @"template"] ;
  8.    
  9.     NSString *categoryName ;
  10.     int say=0;//say is the count of categories in my data struct
  11.     Section *section=[[Section alloc]init];
  12.  
  13.     //template is a dictionary which contains all data structure
  14.     //categoryName contains the name for each section.
  15.     for (categoryName in [template allKeys]) {
  16.          //category is an array of each category from template(in my issue, i want to initialize section.sectionRows with category)
  17.        
  18.         mySection = [template objectForKey:categoryName] ;
  19.           self.sectionArray=[[NSMutableArray alloc]init];
  20.  
  21.         section.sectionHeader=categoryName;
  22.         section.sectionRows=[[NSMutableArray alloc]init];
  23.              for(NSDictionary *aButton in mySection){                          
  24.                  [section.sectionRows addObject:[aButton objectForKey:@"name"]];
  25.                
  26.              }
  27.         say++;
  28.         [self.sectionArray addObject:section];
  29.         NSLog(@"aSection.sectionHeader in loop: %@\n\nsection.sectionRows after here: %@", section.sectionHeader, section.sectionRows);
  30.     }
  31.  
  32.    
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement