How to use varargs….

Hi

Ever wondered how we give multiple button names in alert view other buttons section…and in many more scenarios..

Ok so how we define a function with varargs..

-(void)getMultipleString:(NSString*)firstString ,… NS_REQUIRES_NIL_TERMINATION;


Now the definition

-(void)getMultipleString:(NSString*)firstString ,… NS_REQUIRES_NIL_TERMINATION
{
va_list  t;
va_start(t, firstString);
id obj;
for (obj = firstString; obj != nil; obj = va_arg(t, id))
{
    NSLog(@”%@”,obj);
}
va_end(t);
}
How you call the method….

[self getMultipleString:@”myname”,@”YourName”, nil];

NEED A JOB? NEED TO HIRE? NEED HELP?

Join group of Software Professionals

iOS DEVELOPER’S DEN