On Fri, Dec 12, 2008 at 12:02 PM, Jonathan del Strother <[email protected]> wrote: > On Fri, Dec 12, 2008 at 4:42 PM, Michael Ash <[email protected]> wrote: >> On Fri, Dec 12, 2008 at 9:41 AM, Jonathan del Strother >> <[email protected]> wrote: >>> Maybe an example would be helpful. Let's say I want to call >>> -[Bartender mixCocktailIngredients:(NSString*)ingredient ...], and I >>> want to call that with different arguments depending on the user's >>> preferences. >>> One way of doing so would be to use an if-statement, and just type out >>> all the possibilities: >> >> Why don't you just rewrite -mixCocktailIngredients: to take an NSArray >> instead of variable arguments? Seems like that's ultimately what you >> need anyway, so just change it to be more sane. If you really love >> variable arguments then you can write a vararg version that calls >> through to the NSArray version after marshaling the arguments. > > Sure, if -mixCocktailIngredients: was my own method, but it's not. > I'm calling something in an existing API.
Are you sure there's no non-vararg way to accomplish it? I would consider any API that requires the use of varargs to use multiple objects to be broken. Of course sometimes APIs really are broken and you have to work around that, but I'd definitely first try searching for a way around having to do what you request, or convincing whoever is responsible for this API to un-break it and provide a non-vararg method. Mike _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
