Split a string literal across multiple lines in C / Objective-C

When using long literal strings in you’re code it’s nice to split them up among multiple lines.
To do this the syntax is like this:

In C:

char *my_string = "Line 1 \
                   Line 2";
char *my_string = "Line 1 "
                  "Line 2";

In Objective-C:

NSString *my_string = @"Line1 \
                        Line2";
NSString *my_string = @"Line1" 
                       "Line2";

I personally like the second  options with all quoted nicly;

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>