将NSArray作为otherButtonTitles传递 - iOS

Abr*_*odj 2 iphone ipad ios

目前我正在使用

...otherButtonTitles:@"Hotel Laguna", @"Hotel Village", @"Hotel Torre", @"Hotel Baia", nil];
Run Code Online (Sandbox Code Playgroud)

创造一个UIActionSheet.

我想通过一个NSArray ...类似于:

    NSArray *names = [[NSArray alloc] 
initWithObjects:@"Hotel Laguna", @"Hotel Village", @"Hotel Torre", @"Hotel Baia", nil];

    ...otherButtonTitles:names];
Run Code Online (Sandbox Code Playgroud)

这有可能吗?

谢谢!

Sun*_*uny 5

otherButtonTitles如果在数组中有对象,可以通过枚举数组来添加:

(NSString * title in Strings) 

{ 
[alert addButtonWithTitle:title]; 
}
Run Code Online (Sandbox Code Playgroud)