Last Updated: February 25, 2016
·
1.754K
· _max_k

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];
}

1 Response
Add your response

@[@"object", @"object"];

over 1 year ago ·