【发布时间】:2011-01-26 09:54:01
【问题描述】:
我有一个包含项目的数组,我想将它们传递给一个可变长度的方法。你是怎么做到的?
即,我有这个(例如):
NSArray *array = [NSArray arrayWithObjects:@"1", @"2", @"3", nil];
[[UIAlertView alloc] initWithTitle:@"title" message:@"message" delegate:nil cancelButtonTitle:[array objectAtIndex:0] otherButtonTitles:[array objectAtIndex:1], [array objectAtIndex:2], nil];
但是想象一下,数组可以有可变长度的项目,所以你不能像这样对其进行硬编码。
【问题讨论】:
-
为什么不直接传递数组呢?然后该方法将遍历数组并找出如何处理它。
-
UIAlertView 不这样做。
标签: objective-c variable-length