Skip to content

Instantly share code, notes, and snippets.

@mkuliszkiewicz
Last active December 19, 2015 12:49
Show Gist options
  • Save mkuliszkiewicz/5957646 to your computer and use it in GitHub Desktop.
Save mkuliszkiewicz/5957646 to your computer and use it in GitHub Desktop.
Enumerate table view cells using blocks
//
// UITableView+HLTEnumarateCells.h
//
// Created by Maciej Banasiewicz.
//
#import <UIKit/UIKit.h>
@interface UITableView (HLTEnumarateCells)
- (void)enumarateTableViewCellsUsingBlock:(void(^)(UITableViewCell *))blk;
@end
//
// 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