Skip to content

Instantly share code, notes, and snippets.

@mikelikespie
Created February 10, 2011 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikelikespie/821047 to your computer and use it in GitHub Desktop.
Save mikelikespie/821047 to your computer and use it in GitHub Desktop.
UITableView performance hax
#import "NSIndexPath+RowSectinCache.h"
@interface PairIndexPath : NSObject {
@private
NSUInteger indexes[2];
}
- (NSUInteger)length;
@property (nonatomic, assign, readonly) NSUInteger row;
@property (nonatomic, assign, readonly) NSUInteger section;
- (id) initWithRow:(NSUInteger)row inSection:(NSUInteger)section;
@end
@implementation PairIndexPath
- (id)initWithRow:(NSUInteger)row inSection:(NSUInteger)section {
self = [super init];
if (self) {
indexes[0] = section;
indexes[1] = row;
}
return self;
}
-(NSUInteger)row {
return indexes[1];
}
-(NSUInteger)section {
return indexes[0];
}
- (NSUInteger)length {
return 2;
}
@end
@implementation NSIndexPath (NSIndexPath_RowSectinCache)
+ (NSIndexPath *)indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section;
{
return [[[PairIndexPath alloc] initWithRow:row inSection:section] autorelease];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment