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,354
  • 13
  • 96
  • 143
Marcell
  • 105
  • 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,354
  • 13
  • 96
  • 143
0

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

iHS
  • 5,372
  • 4
  • 31
  • 49