【问题标题】:Unused Entity Issue: Expression result unused XCode 4未使用的实体问题:表达式结果未使用 XCode 4
【发布时间】:2011-07-12 09:38:00
【问题描述】:

有如下代码,在for语句初始化的xs处得到上述错误。没有在 Xcode 3 中得到它,只是在我今天安装 Xcode 4 时出现。 xs 是一个

int xs = 0;
for (xs; xs<3; xs++) {
        if ([colorLayoutArray objectAtIndex:xs] == [colorLayoutArray objectAtIndex:xs+1]){
            rowCorrectCount = rowCorrectCount +1;}
}

有什么线索吗?

【问题讨论】:

  • 你正在粘贴一个片段,所以我们看不到变量声明,尤其是 rowCorrectCount 是什么以及它是如何使用的。

标签: xcode entity xcode4


【解决方案1】:

for() 第一个子句中的“xs”什么也不做。编译器抱怨你可能不是那个意思。您的意思是以下之一:

for (int xs = 0; xs<3; xs++) {
        if ([colorLayoutArray objectAtIndex:xs] == [colorLayoutArray objectAtIndex:xs+1]){
            rowCorrectCount = rowCorrectCount +1;} }

或

int xs = 0;
for (; xs<3; xs++) {
        if ([colorLayoutArray objectAtIndex:xs] == [colorLayoutArray objectAtIndex:xs+1]){
            rowCorrectCount = rowCorrectCount +1;} }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-03
    • 2020-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多