I need help in randomly arranging number sequence in Obj-C for example,
1-4, it'll be 3,1,2,4 or 1,4,3,2. I know it involves this function arc4random()
.
Any suggestions/tips?
Asked
Active
Viewed 515 times
0
-
You may find this helpful http://stackoverflow.com/questions/791232/canonical-way-to-randomize-an-nsarray-in-objective-c – MHC Feb 12 '11 at 15:51
2 Answers
1
Here you can find a Shuffling Category for NSMutableArray
:
0
you can use int iRandomNum = arc4random() % 4
, and use the output accordingly in for loop

iHS
- 5,372
- 4
- 31
- 49