Random pick (Code)

Well I was developing Greek Radio for the iPhone I wanted to add a shuffle shake functionality. It wasn’t that hard, I implemented the accelerometer delegate method and literary all I had to do was to pick a random station from the list.

e.g. random() % [list count];

It was working perfectly, with only one issue; random wasn’t random at all, actually it was playing the stations with the exact same order every time, what the hell?

So anyone has any clue? Just let me know…

Finally random() was replaced with arc4random() which seems to work perfectly :)

Friday, July 3, 2009   ()