FROM : Wayne Hasley
DATE : Sat Aug 12 01:28:41 2006
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
DATE : Sat Aug 12 01:28:41 2006
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
| Related mails | Author | Date |
|---|---|---|
| Roland Silver | Aug 11, 17:55 | |
| Dirk Stegemann | Aug 11, 17:57 | |
| Roland Silver | Aug 11, 18:08 | |
| Dirk Stegemann | Aug 11, 18:19 | |
| Roland Silver | Aug 11, 18:26 | |
| Piers Uso Walter | Aug 11, 18:41 | |
| Joseph Kelly | Aug 11, 18:41 | |
| Dirk Stegemann | Aug 11, 18:47 | |
| Deborah Goldsmith | Aug 11, 23:41 | |
| Andrew Farmer | Aug 12, 00:28 | |
| Wayne Hasley | Aug 12, 01:28 |






Cocoa mail archive

