Created
September 13, 2009 20:27
-
-
Save stevestreza/186319 to your computer and use it in GitHub Desktop.
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
| // | |
| // NSArray+ConcurrencyAdditions.h | |
| // ConcurrencyExtensions | |
| // | |
| // Created by Steve Streza on 9/13/09. | |
| // Copyright 2009 __MyCompanyName__. All rights reserved. | |
| // | |
| #import <Foundation/Foundation.h> | |
| typedef NSObject* (^SSPopulator)(NSUInteger index); | |
| @interface NSArray (ConcurrencyAdditions) | |
| +(NSArray *)SS_arrayWithCount:(NSUInteger)count withOptions:(NSEnumerationOptions)options populator:(SSPopulator)populator; | |
| -(id)SS_arrayByAddingCount:(NSUInteger)count withOptions:(NSEnumerationOptions)options populator:(SSPopulator)populator; | |
| -(id)SS_arrayByInsertingCount:(NSUInteger)count atIndex:(NSUInteger)index withOptions:(NSEnumerationOptions)options populator:(SSPopulator)populator; | |
| @end | |
| @interface NSMutableArray (ConcurrencyAdditions) | |
| -(void)SS_addCount:(NSUInteger)count withOptions:(NSEnumerationOptions)options populator:(SSPopulator)populator; | |
| -(void)SS_insertCount:(NSUInteger)count atIndex:(NSUInteger)index withOptions:(NSEnumerationOptions)options populator:(SSPopulator)populator; | |
| @end |
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
| -(void)doSomething{ | |
| NSArray *myArray = [NSArray SS_arrayWithCount:100 | |
| withOptions:NSEnumerationConcurrent | |
| populator:^(NSUInteger index){ | |
| return [NSNumber numberWithInt:(2 * index + 3)]; | |
| }]; | |
| NSLog(@"My objects: %@",myArray); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment