Not so random?


#1

Hi!

In the employees / assets ownership example, we use NSUInteger randomIndex = random() % [employees count]; to get a random employee and allocate it the previously created asset.

I rebuilt and ran multiple time my program, and the values are always the same - also the same as in the book.

So I tried to NSLog(@"%ld", random()); to see what random() returns, and it constantly returns 1025202362 ?!

Can someone explained what is happening here?


#2

As I understand, it has to do with Random not being so random as we may think. I had the same question. I searched Random in this forum, and found better answers than I can give you :wink: I think it will help you too.