0

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?

Felix
  • 35,239
  • 13
  • 95
  • 142
Marcell
  • 87
  • 7
  • 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 Answers2

1

Here you can find a Shuffling Category for NSMutableArray:

What's the Best Way to Shuffle an NSMutableArray?

Community
  • 1
  • 1
Felix
  • 35,239
  • 13
  • 95
  • 142
0

you can use int iRandomNum = arc4random() % 4, and use the output accordingly in for loop

iHS
  • 5,154
  • 4
  • 30
  • 48