Created
March 26, 2014 08:22
-
-
Save osmszk/9778807 to your computer and use it in GitHub Desktop.
How to shuffle array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSArray *)randomShuffle:(NSMutableArray *)array | |
{ | |
for (NSInteger i=0; i<[array count]; i++) { | |
int exchagingIndex = arc4random() % [array count];//from 0 to count | |
[array exchangeObjectAtIndex:i withObjectAtIndex:exchagingIndex]; | |
} | |
return array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment