Swift choose a random image from an array
<p>Trying to add in a background image that's randomly selected from an external array. The random function is working however it's not injecting the value into the background UIImage.</p>

<p>Code is: </p>

<pre><code>    let chooseImage = images.BackgroundImages
    let randomImage = chooseImage.sample()

    backgroundImage.image = UIImage(named: randomImage)
    print(randomImage)
</code></pre>

<p>The print does show in the correct value and I have tried "(randomImage)" inside the UIImage.</p>

<p>Edit: If I add "(randomImage).jpg" then the code works as intended however will swift infer each type on the device i.e. @2x,@3x etc. Do I need to use the asset name?</p>

<p>Thanks</p>