There are some changes needs to be done with your code. Try the below.
In viewDidLoad,
[self getdata];
[self.mycollectionView reloadData];
In getdata method,
NSArray *arrayFiles = [NSArray arrayWithObjects: dictOriginal, dictOriginal2, dictOriginal3, dictOriginal4, nil];
for (NSDictionary *dict in arrayFiles) {
NSMutableArray *arr = [NSMutableArray array];
NSArray *a = dict[@"files"];
for(int i=0; i < a.count; i ++) {
NSString *strName = [NSString stringWithFormat:@"%@",[[dict[@"files"] objectAtIndex:i] valueForKey:@"name"]];
NSLog(@"str: %@", strName);
[arr addObject:strName];
}
[arrayPDFName addObject:arr];
}
In numberOfItemsInSection,
return ((NSArray *)arrayPDFName[section]).count;
In cellForRowAtIndexPath,
cell.myLabel.text = arrayPDFName[indexPath.section][indexPath.row];
Do this for section title
- Have one mutable array as titleArray or something.
- In viewdidload,
titleArray = [NSMutableArray array];
In getdata method,
NSDictionary *dictOriginal = jsonResults[@“white”];
[titleArray addObject:[NSString stringWithFormat:@"white(%d)", dictOriginal[@"count"]]];
Do the same for dictOriginal2, dictOriginal3, dictOriginal4.
In viewForSupplementaryElementOfKind,
header.myHeaderLabel.text = titleArray[indexPath.section]
In numberOfSectionsInCollectionView,
-(NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return titleArray.count;
}