• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Variable argument methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variable argument methods


  • Subject: Re: Variable argument methods
  • From: Andrew Pinski <email@hidden>
  • Date: Thu, 10 Jul 2003 19:31:53 -0400

I would read a C book about var-args, it is the same in C as it is in Objective-C.

Thanks,
Andrew Pinski



On Thursday, Jul 10, 2003, at 19:24 US/Eastern, Matt Diephouse wrote:

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.
_______________________________________________
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.

References: 
 >Variable argument methods (From: Matt Diephouse <email@hidden>)

  • Prev by Date: Re: How to send a mail from within a program
  • Next by Date: Re: multiple definitions of compare: -- design flaw?
  • Previous by thread: Variable argument methods
  • Next by thread: Re: Variable argument methods
  • Index(es):
    • Date
    • Thread