Skip to content
This repository has been archived by the owner on Jun 2, 2018. It is now read-only.

Useful method added to NSIndexSet+BlocksKit; please consider taking it as my contribution & thanks. #128

Merged
merged 2 commits into from
Apr 2, 2013

Conversation

kaelin
Copy link
Contributor

@kaelin kaelin commented Mar 22, 2013

/** Call the block once for each index and create an array of the return values.

 This method allows transforming indexes into objects:
     int values[10] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
     NSIndexSet *idxs = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 10)];
     NSArray *new = [idxs mapIndex:^id(NSUInteger index) {
       return [NSNumber numberWithInt:values[index]]);
     }];

 @param block A block that returns an object for an index.
 @return Returns an array of the objects returned by the block.
 */
- (NSArray *)mapIndex:(BKIndexMapBlock)block;

zwaldowski added a commit that referenced this pull request Apr 2, 2013
Add -[NSIndexSet mapIndex:] method, thanks to @kaelin.
@zwaldowski zwaldowski merged commit cf30012 into BlocksKit:master Apr 2, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants