ios 数组打乱顺序

-(NSMutableArray*)getRandomArrFrome:(NSArray*)arr
{
    NSMutableArray *newArr = [NSMutableArray new];
    while (newArr.count != arr.count) {
        //生成随机数
        int x =arc4random() % arr.count;
        id obj = arr[x];
        if (![newArr containsObject:obj]) {
            [newArr addObject:obj];
        }
    }
    return newArr;
}

 

NSArray+YYAdd 这个shuffle方法不知道行不行

/**
 Sort the object in this array randomly.
 */
- (void)shuffle;

ios 数组打乱顺序

上一篇:别让手机偷走你的大半生


下一篇:弹出AlertDialog的时候报You need to use a Theme.AppCompat theme (or descendant) with this activity错误