解决编译时出现的警告:format string is not a string literal (potentially insecure)
2012-10-21 23:08
1406 查看
转载自:http://www.cocoachina.com/bbs/read.php?tid=87645
在Xcode 4.2(iOS 5)之前,我猜大家都和我一样很喜欢下面的调试输出写法:
?
但是在Xcode 4.2(iOS 5)之后,貌似苹果更新的编译器,出了支持ARC的Apple LLVM compiler 3.0。然后我发现每次编译,以前的这些输出都会产生一个warning(警告,黄色三角形)。
在StackOverflow和iPhone Dev SDK查找相关答案之后,发现在最新版的编译器里面NSLog为了安全,只接受格式化的字符串,因为NSLog底层也是用printf来格式化输出的。
所以上面的写法都会给出警告,可以把上面的写法修改为以下合法模式:
?
在Xcode 4.2(iOS 5)之前,我猜大家都和我一样很喜欢下面的调试输出写法:
?
在StackOverflow和iPhone Dev SDK查找相关答案之后,发现在最新版的编译器里面NSLog为了安全,只接受格式化的字符串,因为NSLog底层也是用printf来格式化输出的。
所以上面的写法都会给出警告,可以把上面的写法修改为以下合法模式:
?
相关文章推荐
- 解决编译时出现的警告:format string is not a string literal (potentially insecure)
- Xcode 警告信息处理:Format string is not a string literal (potentially insecure)
- Xcode 警告信息处理:Format string is not a string literal (potentially insecure)
- Format string is not a string literal (potentially insecure)
- Codeblocks编译C++出现to_string is not a member of std 或者 to_string was not declared in this scope的解决方法
- C++出现to_string is not a member of std 或者 to_string was not declared in this scope的解决方法
- OSCache的源码编译Cache.java 文件报add(Class, T) in the type EventListenerList is not applicable for the arguments 错误的解决
- Apktool编译出现“error: Public symbol aaa/bbb declared here is not defined.”的解决办法
- 解决ant编译中出现“ warning: 'includeantruntime' was not set,”警告的问题执行ant编译时,
- 异常-----Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string.\u003Cformat> or ?string(format) built-
- yum 安装包 出现Public key for *.rpm is not installed 警告的解决方法
- 解决ORA-01861 literal does not match format string
- Error:The method setInputPaths(JobConf, String) in the type FileInputFormat is not
- Eclipse中使用printf报错 提示参数类型不对 已解决The method printf(String, Object[]) in the type PrintStream is not ap
- core文件出现“is not a core dump: File format not recognized”的原因和解决方法(看/proc/pid/limits)
- C++ 编译出现: error C2871: 'std' : does not exist or is not a namespace 怎么解决
- 解决Jenkins分布式编译iOS代码时,出现"User interaction is not allowed"
- pip安装模块警告InsecurePlatformWarning: A true SSLContext object is not available.
- Android在编译和反编译时出现error: Error: String types not allowed错误的解决办法
- SqlServer2005 恢复数据库时出现Exclusive access could not be obtained because the database is in use 的解决方法