Re: "Tricks" of the "Trade"
Re: "Tricks" of the "Trade"
- Subject: Re: "Tricks" of the "Trade"
- From: Tom Waters <email@hidden>
- Date: Thu, 7 Jun 2001 08:28:18 -0700
From my uses of NSLog, it seems to support the full complement of printf
escapes.
I frequently use x in place of %@ to log the address of objects, and
other pointers.
Also, %g seems to give better results for floats/doubles.
%b isn't for booleans, it's for backslash escape expansion, afaik you
can only print booleans as 0 or 1 %d or use NSLog(@"%@", b?@"YES":@"NO")
On Thursday, June 7, 2001, at 01:47 AM, Rob Rix wrote:
YES, i do agree with you, NSLog() is a wonderful tool. But, I have a
question, if you want to NSLog() to print the value of an int, is
there a
better way than NSLog([[NSNumber numberWithInt:i] stringValue])?
NSLog acts like printf, AFAIK, so you can do something like this:
NSLog(@"The value of the integer is %d", [NSNumber intValue]);
As far as I know, NSLog accepts %d for integers, %f for floats, %c for
chars, %s for char* (C strings), and %@ for objects (you can use this
to display NSStrings, or with other objects, some hex values whose
meaning escapes me).
It might accept others, such as %x, %o (I think those are hex and
octal, but I'm not sure), %b (boolean?), et cetera, but I'm not certain.