I have a UICollectionView
that I am populating with a nested array to help me create sections in my UICollectionView. The final array that I use to populate my UICollectionView
looks like this with each nested array representing a different section in my view:
Array
Array
Dictionary
txt
utc
...
Dictionary
txt
utc
...
Array
Dictionary
txt
utc
...
I want the user to be able filter the collections view based on the txt (or other elements of the dictionary) and then animate the changes in the view using - (void)insertItemsAtIndexPaths:(NSArray *)indexPaths;
or - (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths;
.
Where I need help
I am stuck trying to create the NSArray
of NSIndexSets
that I need for the methods I mentioned above. It seems like indexesOfObjectsPassingTest
of NSIndexSets
would be involved but I can not get it to work properly and any examples I can find are typically just for a single array (How retrieve an index of an NSArray using a NSPredicate?) and I have not been able to adjust the code for my purposes.
Any code to help would be greatly appreciated. Thanks in advance.
I am able to create the NSArray by nesting for loops (which I am not that excited about doing) but it works. If you have any more efficient way to create the array please do let me know!
NSMutableArray *arrayOfIndexes = [[NSMutableArray alloc]init];
for (int i = 0; i < [finalCellData count]; i++) {
for (int ii = 0; ii < [[finalCellData objectAtIndex:i] count]; ii++) {
if (![[[[finalCellData objectAtIndex:i]objectAtIndex:ii]valueForKey:@"txt"] isEqualToString:@""]) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:ii inSection:i];
[arrayOfIndexes addObject:indexPath];
}
}
}