Select Page

Logging has a lot of possible format specifiers. The general syntax of NSLog is:

NSLog(@"Text %@", object);
NSLog(@"I want to log: %@", myString);
 
int i = 1234;
NSLog(@"The number is: %d", i);

The possible format specifiers are:

%@   Object

%d, %i   Signed Integer

%u     Unsigned Integer

%f     Float / Double

%x, %X   Hexidecimal Integer

%o     Octal Integer

%zu   size_t

%p     Pointer

%e     Float / Double (in scientific notation)

%g     Float / Double (as %f or %e, based on value)

%s     C String

%.*s   Pascal String

%c     Character

%C     Unicode Character

%ll     Long Long

%llu   Unsigned Long Long

%Lf   Long Double