UITableView+EnumarateCells.m 890 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // UITableView+HLTEnumarateCells.h
  3. //
  4. // Created by Maciej Banasiewicz.
  5. //
  6. #import "UITableView+EnumarateCells.h"
  7. @implementation UITableView (EnumarateCells)
  8. - (void)enumarateTableViewCellsUsingBlock:(tableviewEnumerateHandler)handler
  9. {
  10. for (int i = 0; i < self.numberOfSections; i++)
  11. {
  12. for (int j = 0; j < [self numberOfRowsInSection:i]; j++)
  13. {
  14. NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:j inSection:i];
  15. handler([self cellForRowAtIndexPath:newIndexPath]);
  16. }
  17. }
  18. }
  19. - (void)enumarateTableViewCellsSection:(NSInteger)section UsingBlock:(tableviewEnumerateHandler)handler {
  20. for (int j = 0; j < [self numberOfRowsInSection:section]; j++)
  21. {
  22. NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:j inSection:section];
  23. handler([self cellForRowAtIndexPath:newIndexPath]);
  24. }
  25. }
  26. @end