title: Is it possible to have a dictionary with a mutable array as the value in Swift
body: <p>I am trying to do this:</p>
  
  <pre><code>var dictArray = [String:[String]]()
  dictArray["test"] = [String]()
  dictArray["test"]! += "hello"
  </code></pre>
  
  <p>But I am getting the weird error <code>NSString is not a subtype of 'DictionaryIndex&lt;String, [(String)]&gt;'</code>.</p>
  
  <p>I just want to be able to add objects to an array inside a dictionary.</p>
  
  <p><strong>Update:</strong> Looks like Apple considers this a "known issue" in Swift, implying it will work as expected <em>eventually</em>. From the Xcode 6 Beta 4 release notes:</p>
  
  <blockquote>
    <p>...Similarly, you cannot modify the underlying value of a mutable
    optional value, either  conditionally or within a force-unwrap:</p>
  
  <pre><code>tableView.sortDescriptors! += NSSortDescriptor(key: "creditName", ascending: true)
  </code></pre>
    
    <p>Workaround: Test the optional value explicitly and then assign the
    result back:</p>
  
  <pre><code>if let window = NSApplication.sharedApplication.mainWindow {
      window.title = "Currently experiencing problems"
  }
  tableView.sortDescriptors = tableView.sortDescriptors!
  </code></pre>
  </blockquote>