• 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: printf with "%@"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >printf with "%@" (From: Roland Silver <email@hidden>)

  • Prev by Date: Re: printf with "%@"
  • Next by Date: Re: redrawing an NSPopUpButtonCell, and ghost effect
  • Previous by thread: Re: printf with "%@"
  • Next by thread: binding to currentDocument
  • Index(es):
    • Date
    • Thread