Xcode 警告:未使用的实体问题:未使用的变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10477266/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode WARNING: Unused Entity Issue: Unused Variable
提问by specht057
I'm working on this tutorial application and the code is giving me this warning:
我正在研究这个教程应用程序,代码给了我这个警告:
Xcode WARNING: Unused Entity Issue: Unused Variable
Xcode 警告:未使用的实体问题:未使用的变量
It's giving the error when executing this statement:
执行此语句时出现错误:
int newRowIndex = [self.checklist.items count];
What's causing it? Which steps should I take to resolve this?
是什么原因造成的?我应该采取哪些步骤来解决这个问题?
回答by Allamaprabhu
The variable newRowIndex
is initialized but not being used anywhere else.
该变量newRowIndex
已初始化但未在其他任何地方使用。
回答by WrightsCS
This warning just means that you created a variable, newRowIndex
, but are not using it anywhere.
此警告仅表示您创建了一个变量newRowIndex
,但并未在任何地方使用它。
To silence the warning, use this int
somewhere, like
要使警告静音,请在int
某处使用它,例如
int newRowIndex = [self.checklist.items count];
NSLog(@"New Row Index: %i", newRowIndex);
回答by silk
It's probably because your build settings might have warnings flagged as errors.
这可能是因为您的构建设置可能有标记为错误的警告。
You can silence warnings (not advised but if you just want to make sure you can build something) by searching for "Warning Policies" and turning "Treat Warnings as Errors" to "No".
您可以通过搜索“警告策略”并将“将警告视为错误”设置为“否”来关闭警告(不建议,但如果您只是想确保可以构建某些内容)。
回答by Mike
If you really want not to receive such warnings any more do the following:
如果您真的不想再收到此类警告,请执行以下操作:
- Go to build settings of your project
- Find "Other Warning Flags" option
- Remove -Werrorand -Wno-unused-parameter
- 转到项目的构建设置
- 找到“其他警告标志”选项
- 删除-Werror和-Wno-unused-parameter