Random number without repeating

前端 未结 3 1682

I have NSMutableArray with 50 array elements. I need to generate randomly without any repetition. Can you suggest some sample codes.

3条回答
  •  盖世英雄少女心
    2020-12-22 08:45

    Create a local mutablearray copy of main array, and after getting random value, remove object available at random index from local array, process it till array count is 1.

提交回复
热议问题