【发布时间】:2014-06-06 20:02:29
【问题描述】:
我可能使用了错误的符号来将 NSString 类型包含在另一个字符串中。
const char* error; //it's set, not nil
NSLog([NSString stringWithFormat : @"Problem with SQL statement in \n %@ \n %@",sqlQuery,[NSString stringWithUTF8String:error]]);
表达式有效,但我收到以下警告:
Formatting string is not a string literal(potentially insecure)
有没有办法摆脱警告?
【问题讨论】:
-
刚刚发布的代码缺少尾随“]”。一如既往地分解复合语句,尤其是在调试时。
NSLog()在每一步之后或使用调试器在每一步之后进行检查。; -
您在
NSLog()中有完整的声明吗? -
是的,它在 NSLog 中,查看编辑
-
摆脱
stringWithFormat:的both使用,并使用%s而不是%@作为error。