包裹NSString stringWithFormat:跨多行

时间:2012-02-17 16:37:59

标签: iphone objective-c

我将我的FMDatabase的SQL语句包装在NSString中。我想用

之类的换行符保持清洁
SELECT * FROM table as t
JOIN location as loc 
on t.position = loc.value

有没有办法在带有换行符的NSString中包装一个长SQL语句(实际语句更长)?我宁愿不创建NSMutableString,然后appendFormat:。感谢。

2 个答案:

答案 0 :(得分:1)

这应该有效:

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

答案 1 :(得分:1)

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