Last active
December 19, 2015 12:49
-
-
Save mkuliszkiewicz/5957646 to your computer and use it in GitHub Desktop.
Enumerate table view cells using blocks
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
// | |
// UITableView+HLTEnumarateCells.h | |
// | |
// Created by Maciej Banasiewicz. | |
// | |
#import <UIKit/UIKit.h> | |
@interface UITableView (HLTEnumarateCells) | |
- (void)enumarateTableViewCellsUsingBlock:(void(^)(UITableViewCell *))blk; | |
@end |
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
// | |
// UITableView+HLTEnumarateCells.h | |
// | |
// Created by Maciej Banasiewicz. | |
// | |
#import "UITableView+HLTEnumarateCells.h" | |
@implementation UITableView (EnumarateCells) | |
- (void)enumarateTableViewCellsUsingBlock:(void(^)(UITableViewCell *))blk | |
{ | |
for (int i = 0; i < self.numberOfSections; i++) | |
{ | |
for (int j = 0; j < [self numberOfRowsInSection:i]; j++) | |
{ | |
NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:j inSection:i]; | |
blk([self cellForRowAtIndexPath:newIndexPath]); | |
} | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment