I have a Card object, that has a flag isFlipped. I store them in a NSMutableArray. I want to check if two objects in my array have the flag on, and if they do, I remove them.
As far as I understand I need to iterate over array, but how do I get another object with a flag?
- (void) checkCards
{
for (Card *card in cards) {
if (card.flipped)
{
if ( ??? )
{
}
}
}
}
Store the index of the cards that you want to remove in variables and if the value of both the variables are set then just remove the cards. See the following