简体   繁体   English

警告:格式不是字符串文字,也没有格式参数

[英]warning: format not a string literal and no format arguments

When i run the below code 当我运行以下代码

NSLog([NSString stringWithFormat:@"Response count is %d",response.products.count]);

i get a warning message like below 我收到如下警告消息

warning: format not a string literal and no format arguments 警告:格式不是字符串文字,也没有格式参数

what is the problem in my syntax.. 我的语法有什么问题。

You don't need to create another autoreleased string, just pass it straight to NSLog : 您无需创建另一个自动发布的字符串,只需将其直接传递给NSLog

NSLog(@"Response count is %d",response.products.count);

The reason why this warning is popping up is because you didn't supply a format string as the first argument to NSLog . 出现此警告的原因是,您没有提供格式字符串作为NSLog的第一个参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM