title: How to split string into Int:String Dictionary
body: <p>So I'm trying to split a string that would look like this:</p>
  
  <pre><code>let Ingredients = "1:egg,4:cheese,2:flour,50:sugar"
  </code></pre>
  
  <p>and I'm attempting to get a dictionary output like this</p>
  
  <pre><code>var decipheredIngredients : [Int:String] = [
  
  1 : "egg",
  4 : "cheese",
  2 : "flour",
  50 : "sugar"
  
  ]
  </code></pre>
  
  <p>Here is the code that I am attempting this with</p>
  
  <pre><code>func decipherIngredients(input: String) -&gt; [String:Int]{
      let splitStringArray = input.split(separator: ",")
      var decipheredIngredients : [String:Int] = [:]
      for _ in splitStringArray {
          decipheredIngredients.append(splitStringArray.split(separator: ":"))
      }
  
      return decipheredIngredients
  }
  </code></pre>
  
  <p>When I try this I get an error saying I can't append to the dictionary.  I've tried other methods like this:</p>
  
  <pre><code>func decipherIngredients(input: String) -&gt; [String.SubSequence]{
      let splitStringArray = input.split(separator: ",")
      return splitStringArray
  }
  
  let newThing = decipherIngredients(input: "1:egg,4:cheese,2:flour,50:sugar").split(separator: ":")
  print(newThing)
  </code></pre>
  
  <p>but I get this as the output of the function</p>
  
  <pre><code>[ArraySlice(["1:egg", "4:cheese", "2:flour", "50:sugar"])]
  </code></pre>