title: Get values from a Array in a Dictionary in Swift
body: <p>My ambition is to have a Dictionary that contains (among other things) an array and being able to get out the values of that array.</p>
  
  <pre><code>var total: Int = 0;
  let dice:[NSTextField:NSArray] = [
          d4Amount:[d4OE, 4],
          d6Amount:[d6OE, 6],
      ];
  
  for (die, dieArray) in dice
  {
      let button:NSButton = dieArray[0] as! NSButton;
      let num:Int = dieArray[1] as! Int;
      total += DoRoll(die, oe: button, max: num);
  }
  </code></pre>
  
  <p>In the above the line "let button:NSButton = dieArray[0]..." get's the error Thread 1: signal SIGABRT and the program fails.
  First I only had the line:</p>
  
  <pre><code>total += DoRoll(die, oe: dieArray[0] as! NS Button, max: dieArray[1] as! Int);
  </code></pre>
  
  <p>Which didn't either work (quite obviously), but however when I do this, it works...</p>
  
  <pre><code>total += DoRoll(d4Amount, oe: d4OE, max: 4);
  </code></pre>
  
  <p>It works perfectly.</p>
  
  <p>Any ideas??</p>
  
  <p>The function DoRoll looks like this (which should not be relevant):</p>
  
  <pre><code>private func DoRoll(amount: NSTextField, oe: NSButton, max: Int) -&gt; Int
  {
      let nrRolls: Int! = Int(amount.stringValue);
      var total: Int = 0;
      if(nrRolls != nil &amp;&amp; nrRolls != 0)
      {
          OutputText.string = OutputText.string! + "Now rolling d" + String(max) + ": ";
          for(var i: Int = 0; i &lt; nrRolls; i++)
          {
              var randomNr: Int, specialMax: Int;
              var textStr: String = "";
  
              specialMax = max;
              if(max &gt;= 100)
              {
                  if(max &gt; 100)
                  {
                      specialMax = 995;
                  }
                  else if(max &gt; 99)
                  {
                      specialMax = 95;
                  }
                  else
                  {
                      specialMax = max - 1;
                  }
              }
  
              repeat
              {
                  randomNr = Int(arc4random_uniform(UInt32(max))) + 1;
                  total += randomNr;
                  if(textStr != "") { textStr = textStr + "+"; }
                  textStr = textStr + String(randomNr);
              } while(oe.state == NSOnState &amp;&amp; randomNr &gt;= specialMax)
  
              OutputText.string = OutputText.string! + textStr + " ";
          }
          OutputText.string = OutputText.string! + "\n";
      }
  
      return total;
  }
  </code></pre>