我一直在尝试为一副纸牌编写应用程序,但我的代码中不断出现错误。错误开启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;
}
}