Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void)createSectionsWithTheirRows{
- NSURL *aURL=[NSURL URLWithString:[NSString stringWithString:@"http://192.168.69.106/ipad/button.php?key=181abc88e57c37a42769"]];
- NSData *data2=[NSData dataWithContentsOfURL:aURL];
- id result2=[NSJSONSerialization JSONObjectWithData:data2 options:NSJSONReadingMutableContainers error:nil];
- NSDictionary *template=[result2 objectForKey: @"template"] ;
- NSString *categoryName ;
- int say=0;//say is the count of categories in my data struct
- Section *section=[[Section alloc]init];
- //template is a dictionary which contains all data structure
- //categoryName contains the name for each section.
- for (categoryName in [template allKeys]) {
- //category is an array of each category from template(in my issue, i want to initialize section.sectionRows with category)
- mySection = [template objectForKey:categoryName] ;
- self.sectionArray=[[NSMutableArray alloc]init];
- section.sectionHeader=categoryName;
- section.sectionRows=[[NSMutableArray alloc]init];
- for(NSDictionary *aButton in mySection){
- [section.sectionRows addObject:[aButton objectForKey:@"name"]];
- }
- say++;
- [self.sectionArray addObject:section];
- NSLog(@"aSection.sectionHeader in loop: %@\n\nsection.sectionRows after here: %@", section.sectionHeader, section.sectionRows);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement