Created
April 18, 2012 17:47
-
-
Save uliwitness/2415382 to your computer and use it in GitHub Desktop.
An (untested) macro and category for easily creating new index sets from unchanging content.
This file contains hidden or 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 NSIndexSet (ULIIndexSetCreation) | |
+(NSIndexSet*) indexSetWithIndexes: (const NSInteger [])indexes count: (NSUInteger)count; | |
@end | |
@implementation NSIndexSet (ULIIndexSetCreation) | |
+(NSIndexSet*) indexSetWithIndexes: (const NSInteger [])indexes count: (NSUInteger)count | |
{ | |
if( count < 1 ) | |
return [NSIndexSet indexSet]; | |
NSMutableIndexSet * muIdxSet = [[[NSMutableIndexSet alloc] initWithIndex: indexes[0]] autorelease]; | |
for( int x = 1; x < count; x++ ) | |
[muIdxSet addIndex: indexes[x]]; | |
return muIdxSet; | |
} | |
@end | |
#define INDEX_SET(destVar, ...) do { NSInteger idxes[] = { __VA_ARGS__ }; (destVar) = [NSIndexSet indexSetWithIndexes: idxes count: sizeof(idxes) /sizeof(NSInteger)]; } while(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment