J W
J W

Reputation: 878

Wrap NSString stringWithFormat: across multiple lines

I am wrapping my SQL statement for FMDatabase in a NSString. I'd like to keep it clean with line returns like

SELECT * FROM table as t
JOIN location as loc 
on t.position = loc.value

Is there a way to wrap a long SQL statement (the actual statement is much longer) in an NSString with line breaks? I'd rather not create a NSMutableString, and then appendFormat:. Thanks.

Upvotes: 0

Views: 231

Answers (2)

beryllium
beryllium

Reputation: 29767

NSString *query = @"SELECT * FROM table as t \
                    JOIN location as loc \
                    on t.position = loc.value";

Upvotes: 1

zoul
zoul

Reputation: 104065

This should work:

NSString *statement =
    @"line1\n"
     "line2\n"
     "line3\n";

Upvotes: 1

Related Questions