Re-arrange NSArray/MSMutableArray in random order

后端 未结 4 1450
余生分开走
余生分开走 2020-12-01 11:32

I\'m using NSArray/NSMutable array to store different objects. Once all the objects are added, I want to re-arrange them in random order. How can I do it?

4条回答
  •  孤街浪徒
    2020-12-01 11:50

    Link GameplayKit/GameplayKit.h in your project then

    #import 
    

    Now you can use the property shuffledArray.

    NSArray *randomArray = [yourArray shuffledArray];
    

提交回复
热议问题