How can I spot a random number generator in Swift?

My application uses random numbers. I would like to sow a random number generator so that every time it is not the same. How can i do this?

EDIT:

What parameter should I give srand () in order to plant a random generator with the current time?

+5
source share
1 answer

It works:

let time = UInt32(NSDate().timeIntervalSinceReferenceDate) srand(time) print("Random number: \(rand()%10)") 
+8
source

Source: https://habr.com/ru/post/1202785/


All Articles