The Random() function


//Get a random number between 0 and 9 inclusive NSUInteger randomIndex = random() % [employees count];

I’m sure of all the code up until this point. What I don’t understand is what number is the random function generating exactly, and if it’s suppose to be random how come I keep getting the same numbers every time ? Is there a way to see this in the debugger ?


I was always taught that computers don’t actually generate random numbers. “Seeding” the random number generator will produce more random results. So far up to this chapter in the book, we’ve only used random(), which you’ve noticed isn’t random at all. Use arc4random() wherever the book says random(). You’ll get the random numbers you’re looking for without having to worry about seeding or anything.