Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate NSArray to a list of NSString type objects

A UIActionSheet is initalized with:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil 
otherButtonTitles:@"Button1", @"Button2", nil];

I am trying to pass an NSArray into the "otherButtonTitles" message.

I tried to pass an NSArray using:

otherButtonTitles:[array]

but the message is expecting a list of NSStrings.

The only way I can think of breaking an NSArray into a set of NSStrings is to by using componentsJoinedByString but it gives me a comma separated list that is a single NSString.

A point in the right direction would be appreciated.

like image 953
Michael Shnitzer Avatar asked Jun 20 '09 02:06

Michael Shnitzer


2 Answers

That method takes varargs. There's not a really easy way to make the conversion your describing, and it definitely isn't worth the trouble to try in this case. This is just a convenience method.

Just use -init and configure everything with the accessors (-setDelegate:, -addButtonWithTitle:, -setCancelButtonIndex:, etc.)

like image 159
Rob Napier Avatar answered Oct 15 '22 06:10

Rob Napier


Unfortunately, you can't do this in Objective-C.

like image 30
Chuck Avatar answered Oct 15 '22 07:10

Chuck