Say for example this is my C ( & Objective-C ) method as follows.
void ALERT(NSString *title, NSString *message,NSString *canceBtnTitle,id delegate,NSString *otherButtonTitles, ... )
{
// HERE I CAN ACCESS ALL THOSE ARGUMENTS
// BUT I AM NOT SURE How to access additional arguments, supplied using ... ?
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:title
message:message
delegate:delegate
cancelButtonTitle:canceBtnTitle
otherButtonTitles:// how to pass those params here?];
}
As you can notice that, I also have to pass those parameters in UIAlertView‘s init method. I am not sure how to send those parameters into otherButtonTitles. I can invoke this method by following ways.
ALERT(@"My Alert Title",@"Alert Subtitle",@"YES",viewCtr,@"No",@"May Be",@"Cancel",nil);
ALERT(@"Alert Title",@"Alert Subtitle",@"OK",viewCtr,@"Cancel",nil);
ALERT(@"Alert Title",@"Alert Subtitle",@"OK",viewCtr,nil);
ALERT(@"Alert Title",@"Alert Subtitle",@"OK",viewCtr,@"Option1",@"Option2",nil);
Sounds like you need to get know va_arg (and va_list, va_start, va_end).
Here’s a tutorial on the subject.
Also, a fine Apple tech note entitled “How can I write a method that takes a variable number of arguments, like NSString’s +stringWithFormat:?”
Edited to add:
Sounds like you want to do
va_copy.Ahh, here is a related question.