Re: variadic function
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