2

有如下代码,在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;}
}

有什么线索吗?

4

1 回答 1

7

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

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;} }
于 2011-03-10T02:51:18.510 回答