Created
February 10, 2011 18:29
-
-
Save mikelikespie/821047 to your computer and use it in GitHub Desktop.
UITableView performance hax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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