Generate random number with arc4random_uniform : <p>I want to generate some random numbers (1 to limit) and store them with an array. Here's my codes:</p>

<pre><code>var results = [Int]()
    for i in 0...qut
    {
        let lim = limit - 1
        results[i] = Int(arc4random_uniform(lim)) + 1
    }
</code></pre>

<p>And then xcode told me that "Cannot convert value of type 'Int' to expected argument type 'UInt32'. "</p>

<p>So I made some changes:</p>

<pre><code>results[i] = Int(arc4random_uniform(UInt32(lim))) + 1
</code></pre>

<p>There's no error now. But when I run it, it report an error: "Fatal error: Index out of range."</p>

<p>Could someone tell me how can I fix that?</p>
