Question: *I am new to StackOverflow so please correct me if there is a better way to post a question which is a specific case of an existing question.*

Alberto Barrera answered 
[How does one seed the random number generator in Swift?](https://stackoverflow.com/questions/25895081/how-does-one-seed-the-random-number-generator-in-swift)

with 

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

```

which is perfect generally, but when I try it in [The IBM Swift Sandbox](http://swiftlang.ng.bluemix.net/#/repl) it gives the same number sequence every run, at least in the space of a half hour.

```
import Foundation
import CoreFoundation

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

```

At the moment, every Run prints 5.

Has anyone found a way to do this in the IBM Sandbox? I have found that random() and srandom() produce a different number sequence but similarly are the same each Run. I haven't found arc4random() in Foundation, CoreFoundation, Darwin, or Glibc.

*As an aside, I humbly suggest someone with reputation above 1500 creates a tag IBM-Swift-Sandbox.*

Answer: 
`srand` is working as expected. If you change value each time in `let time = UInt32(NSDate().timeIntervalSinceReferenceDate)` instead of `NSDate().timeIntervalSinceReferenceDate` with any number, it will output random numbers.

Maybe this is a caching issue, it just doesn't see any changes in code and doesn't send it for recompilation :)
I don't know what is going on but today it is totally working. So I guess the question is answered: 

```
srand(UInt32(NSDate().timeIntervalSinceReferenceDate))

```

works fine.

(I think something must have changed. It was behaving the same way (generating the same number with repeated attempts) on two different computers for about 10 days... Bizarre.)