This is a bit awkward, but possible:
- (id)method:(NSString *)arg1, ... {
va_list args;
va_start(args, arg1);
for (NSString *a = arg1; a!= nil; a= va_arg(args, NSString*)) {
}
}
It arg1will usually be a string that defines the data types and the number of additional parameters.
You would call it this way:
[self method:@"5", @"4", @"3", @"2", @"1"];
Your array method is probably more clear for most purposes.
source
share