Variable argument methods
Variable argument methods
- Subject: Variable argument methods
- From: Matt Diephouse <email@hidden>
- Date: Thu, 10 Jul 2003 19:24:00 -0400
Hi. I'm new to Cocoa and Objective-C. I've only done programming in
Perl, Ruby, and Python before.
I'm trying to write a method that takes a variable number of arguments.
I've searched the archives and the net for examples, but haven't
understood anything I've come up with. I want to take the following
method (which is untested) and make so I'm not using an array to pass
arguments.
- (BOOL)sendCommand: (NSString *)cmd
withArgs: (NSArray *)args;
Here's an example of how I want its usage to look.
[class sendCommand:@"article"
withArgs:@"one", @"two", @"three"];
I think I need to use va_list and and associated functions, but I'm not
sure how they work. I've also seen it mentioned that two methods are
actually needed. Could someone please explain this for me? Please keep
in mind that I'm not used to dealing with types this way, having come
from a predominantly Perl background. Thanks,
matt
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.