Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jeremy1026

macrumors 68020
Nov 3, 2007
2,215
1,029
With shuffling cards for a card game.

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

Code:
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.