Skip to content

Instantly share code, notes, and snippets.

@osmszk
Created March 26, 2014 08:22
Show Gist options
  • Save osmszk/9778807 to your computer and use it in GitHub Desktop.
Save osmszk/9778807 to your computer and use it in GitHub Desktop.
How to shuffle array
- (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