PDA

View Full Version : Need some help




iphonedevelop18
Apr 5, 2009, 12:23 AM
With shuffling cards for a card game.



Jeremy1026
Apr 5, 2009, 01:17 AM
With shuffling cards for a card game.

I actually did something like this for another project (it wasnt cards though.)



for (int j = 0; j < numberArray.count; j++) {
int randomIndex = [[NSNumber numberWithInt:0 + arc4random() % 52] integerValue];
[numberArray exchangeObjectAtIndex:j withObjectAtIndex:randomIndex];
}



So, 1st put the 52 cards into an array, then run that code to shuffle it :). It seems to work okay for me.

iphonedevelop18
Apr 5, 2009, 10:30 AM
how do I go about putting the cards into an array?