Reputation: 23
I am using Xcode 5 , I write this method but unfortunately this error appear: USE OF UNDECLARED IDENTIFIER otherCard. Although I declare it in the for loop:
- (void)chooseCardAtIndex:(NSUInteger)index{
card *card =[self cardAtIndex:index];
if(card.isMatched){
if(card.isChosen){
card.chosen =NO;
}else {
for(card *otherCard in self.cards){
if(otherCard.isChosen && !otherCard.isMatched){
int matchScore =[card match:@[otherCard]];
if(matchScore){
self.score +=matchScore;
} else {
self.score -= MISMATCH_PENALTY;
}
}
}
}
}
}
thank you in advance
Upvotes: 0
Views: 81
Reputation: 47709
The problem is that when you defined variable card
to be of class card
earlier you hid the definition of class card
. (A good reason to use the standard naming convention where class names always start with an Upper Case character.)
Upvotes: 1
Reputation: 13323
This line may be throwing off the compiler:
card *card =[self cardAtIndex:index];
Is card the class type or the variable name? It can't be both.
Upvotes: 2