Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass variable number of arguments to method2 from method1 that takes a variable number of arguments?

Tags:

Assume that we have methods:

-(instancetype) initWithElements:(id)firstElement, ... NS_REQUIRES_NIL_TERMINATION;
+(instancetype) objWithElements:(id)firstElement, ... NS_REQUIRES_NIL_TERMINATION;

I understand, how to work with variable number of arguments in -initWithElements:, but I don't understand how to pass variables from -objWithElements: to -initWithElements:.

I mean, I want to write something like:

+(instancetype) objWithElements:(id)firstElement, ... NS_REQUIRES_NIL_TERMINATION {
    return [[[self] initWithElements:ELEMENTS] autorelease];
}

Is it even possible?

The only solution for my problem I see is to store arguments in array and use helper method that will init object with given array.