可变参数函数(stdarg.h)的使用
2013/5/3记录:
stdarg.h数据类型
类型名称
|
描述
|
相容
|
va_list
|
用来保存宏va_arg与宏va_end所需信息
|
C89
|
stdarg.h宏
巨集名称
|
描述
|
相容
|
va_start
|
使va_list指向起始的参数
|
C89
|
va_arg
|
检索参数
|
C89
|
va_end
|
释放va_list
|
C89
|
va_copy
|
拷贝va_list的内容
|
C99
|
- (void)showAlert:(id)sender Title:(NSString*)title Message:(NSString*)message cancelButton:(NSString*)cancelbutton otherButton:(NSString*)otherbutton,... { UIAlertView*alert = [[UIAlertViewalloc] initWithTitle:title message:message delegate:sender cancelButtonTitle:cancelbutton otherButtonTitles:otherbutton,nil]; id eachObject; va_list argumentList; if (otherbutton) { va_start(argumentList, otherbutton); while ((eachObject = va_arg(argumentList, id))) { NSString *str = [NSStringstringWithFormat:@"%@",eachObject]; [alert addButtonWithTitle:str]; } va_end(argumentList); } [alert show]; [alert release]; }