OC实现将N个数随机排列 撩课

 1 + (NSMutableArray *)randArray : (NSMutableArray *)arrayM
 2 {
 3 
 4     NSMutableArray *resultM = [[NSMutableArray alloc] initWithCapacity:arrayM.count];
 5     NSInteger count = arrayM.count;
 6     for (NSInteger i = 0; i < count; i ++)
 7     {
 8         NSInteger index = arc4random_uniform((unsigned int)arrayM.count);
 9         [resultM addObject:[arrayM objectAtIndex:index]];
10         [arrayM removeObjectAtIndex:index];
11         
12     }
13     return resultM;
14 }
原文地址:https://www.cnblogs.com/dashunzi/p/3732872.html