wdmsyf 发表于 2013-1-16 18:21:02

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选项”来去掉。截图如下:
 
http://dl.iteye.com/upload/attachment/352750/f1da6629-6847-3019-8610-85d20c1ee479.png
 
 
相关资料地址: http://stackoverflow.com/questions/1677824/snowleopard-xcode-warning-format-not-a-string-literal-and-no-format-arguments
页: [1]
查看完整版本: NSLog warning:”format not a string literal and no format arguments”的临时解决方法