Created
February 13, 2016 23:01
-
-
Save vikdenic/c97c1acdedd5acdd3aa8 to your computer and use it in GitHub Desktop.
Objective-C Category to return all cells from a UICollectionView instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import "UICollectionView+CellRetrieval.h" | |
| @implementation UICollectionView (CellRetrieval) | |
| -(NSArray *) allCells { | |
| NSMutableArray *cells = [[NSMutableArray alloc] init]; | |
| for (NSInteger j = 0; j < [self numberOfSections]; ++j) | |
| { | |
| for (NSInteger i = 0; i < [self numberOfItemsInSection:j]; ++i) | |
| { | |
| [cells addObject:[self cellForItemAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]]]; | |
| } | |
| } | |
| return [cells copy]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment