Saturday, November 17, 2012

NSLog Format Specifiers

These formatters are used with NSLog, and also Logging.h mentioned in a previous post. Take a look.

%d, %isigned int
%uunsigned int
%ffloat or double
%efloat or double in standard form or scientific notation
%xhex int
%Xhex int
%ooctal int
%ccharacter
%Cunichar
%@object

Examples:

(1)
int num=9;
NSLog(@"The value of the integer is %i", num);

Result: The value of the integer is 9



(2)
NSDate *today= [NSDate date];
NSLog(@"the date is %@",today);

Result:  the date is 2012-11-17 01:15:00 +0000

No comments:

Post a Comment