Skip navigation.
 
mlRe: printf with "%@"
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

Related mailsAuthorDate
mlprintf with "%@" Roland Silver Aug 11, 17:55
mlRe: printf with "%@" Dirk Stegemann Aug 11, 17:57
mlRe: printf with "%@" Roland Silver Aug 11, 18:08
mlRe: printf with "%@" Dirk Stegemann Aug 11, 18:19
mlRe: printf with "%@" Roland Silver Aug 11, 18:26
mlRe: printf with "%@" Piers Uso Walter Aug 11, 18:41
mlRe: printf with "%@" Joseph Kelly Aug 11, 18:41
mlRe: printf with "%@" Dirk Stegemann Aug 11, 18:47
mlRe: printf with "%@" Deborah Goldsmith Aug 11, 23:41
mlRe: printf with "%@" Andrew Farmer Aug 12, 00:28
mlRe: printf with "%@" Wayne Hasley Aug 12, 01:28