Need some help

Discussion in 'iPhone/iPad Programming' started by iphonedevelop18, Apr 4, 2009.

  1. macrumors member

    Joined:
    Feb 26, 2009
    #1
    With shuffling cards for a card game.
     
  2. macrumors 68000

    Joined:
    Nov 3, 2007
    #2
    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.
     
  3. thread starter macrumors member

    Joined:
    Feb 26, 2009
    #3
    how do I go about putting the cards into an array?
     

Share This Page