Re: printf with "%@"
Re: printf with "%@"
- Subject: Re: printf with "%@"
- From: Wayne Hasley <email@hidden>
- Date: Fri, 11 Aug 2006 16:28:41 -0700
On Aug 11, 2006, at 8:55 AM, Roland Silver wrote:
Is there a function/method available in the Cocoa API that's like
printf, except for
allowing "%@" usage:
Roland!
You need to write your own...
From <http://borkware.com/quickies/one?topic=General>
Hacks
A Quieter NSLog
// NSLog() writes out entirely too much stuff. Most of the time I'm
// not interested in the program name, process ID, and current time
// down to the subsecond level.
// This takes an NSString with printf-style format, and outputs it.
// regular old printf can't be used instead because it doesn't
// support the '%@' format option.
void QuietLog (NSString *format, ...)
{
// get a reference to the arguments on the stack that follow
// the format paramter
va_list argList;
va_start (argList, format);
// NSString luckily provides us with this handy method which
// will do all the work for us, including %@
NSString *string;
string = [[NSString alloc] initWithFormat: format
arguments: argList];
va_end (argList);
// send it to standard out.
printf ("%s\n", [string UTF8String]);
[string release];
} // QuietLog
Wayne
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden