Nick
Nick

Reputation: 2911

Method with variable arguments followed by non-varargs

I get that you can do something like this:

 +(id) objectWithItems: (NSObject *) item, ...;

However I was wondering if it was possible to do something like this (I cannot get this to compile):

 +(id) objectWithItems: (NSObject *) item, ... withValue:(int)val;

So that I could do:

 MyClass *c = [c objectWithItems:a,b,c,nil withValue:5];

Is this possible?

I guess I could just invert the parameters...

 +(id) objectWithValue:(int) val withItems: (NSObject *) item, ...;
 MyClass *c = [c objectWithValue:5 withItems:a,b,c,nil];

Upvotes: 3

Views: 161

Answers (1)

Carl Norum
Carl Norum

Reputation: 224944

Nope, sorry. The variadic part of your method signature has to be at the end.

Upvotes: 5

Related Questions