title: Swift: Creating an array of UIImage
body: <p>Using Swift, I'm trying to create an array of UIImage objects for a simple animation. Contextual help for <code>animationImages</code> reads, "The array must contain UI Image objects."</p>
  
  <p>I've tried to create said array as follows, but can't seem to get the syntax correct:</p>
  
  <pre><code>var logoImages: UIImage[]
  logoImages[0] = UIImage(name: "logo.png")
  </code></pre>
  
  <p>This throws:
  ! Variable logoImages used before being initialized</p>
  
  <p>Then I tried</p>
  
  <pre><code>var logoImages = []
  logoImages[0] = UIImage(named: "logo.png")
  </code></pre>
  
  <p>Which throws:
  ! Cannot assign to the result of this expression</p>
  
  <p>I've checked the docs here, but the context isn't the same:
  <a href="https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/CollectionTypes.html" rel="noreferrer">https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/CollectionTypes.html</a></p>