title: Create mutable Dictionary with dynamic value/keys in SWIFT
body: <p>I need to create a Dictionary with dynamic keys. </p>
  
  <p>At the end I need a Dictionary</p>
  
  <p>I tried to use:</p>
  
  <pre><code>var animDictionary:[String:AnyObject]
  
      for position in 1...10
      {
          let strImageName : String = "anim-\(position)"
          let image  = UIImage(named:strImageName)
          animDictionary.setValue(image, forKey: strImageName) //NOT WORK 
         //BECAUSE IT'S NOT A NSMUTABLEDICTIONARY
      }
  </code></pre>
  
  <p>So I tried:</p>
  
  <pre><code>var animMutableDictionary=NSMutableDictionary&lt;String,AnyObject&gt;()
  
      for position in 1...10
      {
          let strImageName : String = "anim-\(position)"
          let image  = UIImage(named:strImageName)
          animMutableDictionary.setValue(image, forKey: strImageName) 
      }
  </code></pre>
  
  <p>But I don't find the how to convert my NSMutableDictionary to a Dictionary. I'm not sure it's possible.</p>
  
  <p>In the Apple doc, I found :</p>
  
  <p><a href="https://i.stack.imgur.com/xvSXb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xvSXb.png" alt="Apple Doc"></a></p>
  
  <p>I don't know if it's possible to use it in my case.</p>