How to use varargs….

      No Comments on How to use varargs….

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))
How you call the method….

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