• 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: variadic function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variadic function


  • Subject: Re: variadic function
  • From: "Shawn Erickson" <email@hidden>
  • Date: Fri, 18 May 2007 17:08:28 -0700

On 5/18/07, Ricky Sharp <email@hidden> wrote:

On May 18, 2007, at 6:24 PM, Roland Silver wrote:

> How can I write a variadic function foo(NSString* format, ...) in
> such a way that it can have, in effect, in its body:
> NSString* msg = [NSString stringWithFormat:format, ...];

Please do at least some searching.  Googling on 'cocoa variadic'
brought up as a first hit:

<http://developer.apple.com/qa/qa2005/qa1405.html>

Actually I don't think that answers the exact question he asked. I think however the following does...

-[NSString initWithFormat:arguments:]

...for example...

NSString* foo(NSString* format, ...) {
   va_list arguments;
   va_start(arguments, format);
   NSString* string = [[[NSString alloc] initWithFormat:format
arguments:arguments]autorelease];
   va_end(arguments);
   return string;
}
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >variadic function (From: Roland Silver <email@hidden>)
 >Re: variadic function (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Re: variadic function
  • Next by Date: Re: Use of "min" and "max" functions
  • Previous by thread: Re: variadic function
  • Next by thread: Dock icon removal. and NSStatusBar
  • Index(es):
    • Date
    • Thread