UITableView+EnumarateCells.m 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. BOOL stop = NO;
  11. for (int i = 0; i < self.numberOfSections; i++)
  12. {
  13. for (int j = 0; j < [self numberOfRowsInSection:i]; j++)
  14. {
  15. NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:j inSection:i];
  16. handler([self cellForRowAtIndexPath:newIndexPath], &stop);
  17. if (stop) {
  18. break;
  19. }
  20. }
  21. if (stop) {
  22. break;
  23. }
  24. }
  25. }
  26. - (void)enumarateTableViewCellsSection:(NSInteger)section UsingBlock:(tableviewEnumerateHandler)handler {
  27. BOOL stop = NO;
  28. for (int j = 0; j < [self numberOfRowsInSection:section]; j++)
  29. {
  30. NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:j inSection:section];
  31. handler([self cellForRowAtIndexPath:newIndexPath], &stop);
  32. if (stop) {
  33. break;
  34. }
  35. }
  36. }
  37. @end