Quick NSArray creation (objective-c)
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];
}
Written by Max Kramer
Related protips
1 Response
@[@"object", @"object"];
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Nsarray
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#