读书人

NSLog warning:”format not a string

发布时间: 2012-08-21 13:00:21 作者: rapoo

NSLog warning:”format not a string literal and no format arguments”的临时解决方法

在以前的Mac OSX版本中,用Objective c写程序时,写这样一句是没有任何问题的:
----------------------
NSString *name = @"Mimi";
NSLog(name);

而到了SnowLeopard,用上Xcode 3.2之后,如果这么写总是会有一个“format not a string literal and no format arguments”warning, 虽说这个Warning不管它也没什么,但让有洁癖的人总是心里疙疙瘩瘩的。

究其原因,这个Warning的产生是因为在GCC 4.2中使用了更严格的类型检测所致。

这个问题貌似还没有很完美的解决办法。如果真的看着这些Warning心烦的话,可以在xcode里通过禁用“Typecheck Calls to printf/scanf选项”来去掉。截图如下:

?
NSLog warning:”format not a string literal and no format arguments”的临时解决办法
?

?

相关资料地址: http://stackoverflow.com/questions/1677824/snowleopard-xcode-warning-format-not-a-string-literal-and-no-format-arguments

读书人网 >移动开发

热点推荐