2011-03-10 5 views
2

次のコードがあり、for文のinitilizationのxsで上記のエラーが発生します。 Xcode 3でそれを取得していない、ちょうど私がXcode 4を今日インストールしたときに現れた。 xsは未使用のエンティティ問題:未使用の式結果XCode 4

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

手がかりはありますか?

+0

あなたはフラグメントを貼り付けているので、私たちはrowCorrectCountは、それが使われている方法で、特に何、変数宣言を見ることができません。 –

答えて

7

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;} }