Hi
I currently try to fill and NSMutableArray with something like this:
deck = [[NSMutableArray alloc] initWithCapacity:52];
for (int suit = 0; suit <= 3; suit++) {
for (int value = 1; value <= 13; value++) {
ANormalCard *card = [[ANormalCard alloc] initWithSuit:suit value:value];
[deck addObject:card];
[card autorelease];
}
}
Now the problem is when I go over the array, only the last object I create is 52x in the array. Any idea what I am doing wrong ?
Edit:
the -initWithSuit looks like this:
- (id) initWithSuit:(int)suit value:(int)val {
if ((self = [super init])) {
theSuit = suit;
theValue = val;
}
return self;
}
I'm using NSEnumerator * enumerator = [deck objectEnumerator];
and a while loop to iterate over the array.