0005-Use-array-for-storing-reusable-cell.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. From 5655c1d8eb63f0a505455610dd1b56f3be444deb Mon Sep 17 00:00:00 2001
  2. From: Gleb Pinigin <gpinigin@gmail.com>
  3. Date: Tue, 11 Jun 2013 22:33:42 +0700
  4. Subject: [PATCH 5/5] Use array for storing reusable cell
  5. ---
  6. Classes/AQGridView.m | 10 +++++-----
  7. 1 file changed, 5 insertions(+), 5 deletions(-)
  8. diff --git a/Classes/AQGridView.m b/Classes/AQGridView.m
  9. index aaa0c9a..1ab0df0 100755
  10. --- a/Classes/AQGridView.m
  11. +++ b/Classes/AQGridView.m
  12. @@ -574,8 +574,8 @@ NSString * const AQGridViewSelectionDidChangeNotification = @"AQGridViewSelectio
  13. - (AQGridViewCell *) dequeueReusableCellWithIdentifier: (NSString *) reuseIdentifier
  14. {
  15. - NSMutableSet * cells = _reusableGridCells[reuseIdentifier];
  16. - AQGridViewCell * cell = [cells anyObject];
  17. + NSMutableArray * cells = _reusableGridCells[reuseIdentifier];
  18. + AQGridViewCell * cell = [cells lastObject];
  19. if ( cell == nil )
  20. return ( nil );
  21. @@ -589,13 +589,13 @@ NSString * const AQGridViewSelectionDidChangeNotification = @"AQGridViewSelectio
  22. {
  23. for ( AQGridViewCell * cell in reusableCells )
  24. {
  25. - NSMutableSet * reuseSet = _reusableGridCells[cell.reuseIdentifier];
  26. + NSMutableArray * reuseSet = _reusableGridCells[cell.reuseIdentifier];
  27. if ( reuseSet == nil )
  28. {
  29. - reuseSet = [[NSMutableSet alloc] initWithCapacity: 32];
  30. + reuseSet = [[NSMutableArray alloc] initWithCapacity: 32];
  31. _reusableGridCells[cell.reuseIdentifier] = reuseSet;
  32. }
  33. - else if ( [reuseSet member: cell] == cell )
  34. + else if ( [reuseSet containsObject:cell] )
  35. {
  36. NSLog( @"Warning: tried to add duplicate gridview cell" );
  37. continue;
  38. --
  39. 1.7.12.4 (Apple Git-37)