-
-
Save mikeabdullah/8956676 to your computer and use it in GitHub Desktop.
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
extern NSArray *PRHArrayByMap(NSArray *inArray, id (^block)(id)); |
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
NSArray *PRHArrayByMap(NSArray *inArray, id (^block)(id)) { | |
if (inArray == nil) | |
return nil; | |
NSCParameterAssert(block != nil); | |
NSMutableArray *outArray = [NSMutableArray arrayWithCapacity:inArray.count]; | |
for (id obj in inArray) { | |
id result = block(obj); | |
NSCAssert(result != nil, @"%s: block(%@) returned nil—array follows\n%@", __func__, obj, inArray); | |
[outArray addObject:result]; | |
} | |
return outArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment