This is an object I made to do some flash cards. The first method (I left out the main part) generates a NSMutabaleArray of Card objects with the passed in operator and works fine. The second method, "drawFromDeck" gets called on a Deck object from my view controller and also works fine, but the Static Analyzer says I may be leaking an object.
Here is the code.
#import "Deck.h"
@class Deck;
@implementation Deck
@synthesize cards;
- (id)initDeckWithOperator: (NSString*)mathOper {
...
return self;
}
- (id)drawFromDeck {
int index = random() % [cards count];
Card* selectedCard = [[cards objectAtIndex:index] retain];
[cards removeObjectAtIndex:index];
return selectedCard;
}
@end