0
我一直在嘗試爲一副紙牌寫一個應用程序,但我一直在我的代碼中收到錯誤。錯誤在otherCard
上,並且說快速枚舉循環中未聲明的標識符錯誤
未聲明的標識otherCard。
#define MATCH_BONUS 4
#define MISMATCH_PENALTY 2
#define FLIP_COST 1
- (void)flipCardAtIndex:(NSUInteger)index
{
card *card = [self cardAtIndex:index];
if (!card.isUnplayable){
if(!card.isFaceUp){
for (card *otherCard in self.cards) {
if (otherCard.isFaceUp && !otherCard.isUnplayable) {
int matchscore = [card match: @[otherCard]];
if (matchscore) {
otherCard.unplayable = YES;
card.unplayable = YES;
self.score += matchscore * MATCH_BONUS;
} else {
otherCard.faceUp = NO;
self.score -= MISMATCH_PENALTY;
}
break;
}
}
self.score -= FLIP_COST;
}
card.faceUp = !card.isFaceUp;
}
}
它告訴你錯誤是在哪一行嗎? –
將你的'卡'類改爲'卡'。你在本地掩蓋它,所以每個循環都會失敗。 – thegrinner