NSLog, and its corresponding C function printf(), use escape sequences to print certain characters that are “invisible.” For iOS, include:


There are others, such as \a for Alert, but they are rarely used, and don’t make an effect.

Format specifiers, however, are the percent character, followed by a letter, such as %d or %f that tell NSLog or printf() to print the value or result of a variable, value, and/or expression.

Click here for a list of C format specifiers.

Just think of them as types of placeholders, each designed to represent a different value.

This post is part of the Learn Objective-C in 24 Days course.

Author: Feifan Zhou