Created
February 17, 2013 07:39
-
-
Save CodaFi/4970568 to your computer and use it in GitHub Desktop.
Create NSIndexPaths the easy way.
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
@interface NSIndexPath (CFIAdditions) | |
#ifdef TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED <= 60000 | |
+ (NSIndexPath *)indexPathForRow:(NSInteger)row inSection:(NSInteger)section; | |
+ (NSIndexPath *)indexPathForItem:(NSInteger)item inSection:(NSInteger)section; | |
#endif | |
@end | |
@implementation NSIndexPath (CFIAdditions) | |
#ifdef TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED <= 60000 | |
+ (NSIndexPath *)indexPathForRow:(NSInteger)row inSection:(NSInteger)section { | |
NSUInteger indexArr[] = {section, row}; | |
return [NSIndexPath indexPathWithIndexes:indexArr length:2]; | |
} | |
+ (NSIndexPath *)indexPathForItem:(NSInteger)item inSection:(NSInteger)section { | |
NSUInteger indexArr[] = {section, item}; | |
return [NSIndexPath indexPathWithIndexes:indexArr length:2]; | |
} | |
#endif | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment