Created
August 8, 2012 16:47
-
-
Save maxkramer/3296555 to your computer and use it in GitHub Desktop.
Quick NSArray creation objective-c
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 *arrayCreate(id firstObject, ...) { | |
NSMutableArray *objects = [NSMutableArray array]; | |
[objects addObject:firstObject]; | |
va_list args; | |
va_start(args, firstObject); | |
id arg; | |
while ((arg = va_arg(args, id))) { | |
if (arg == nil) | |
break; | |
[objects addObject:arg]; | |
} | |
va_end(args); | |
return [objects copy]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment