title: Swift 3 iterate over a nested Dictionary?
body: <p>Okay, so, swift noob alert:</p>
  
  <p>How do I do the simplest of iterations given the following array (I dont know what to call this shape: array, dictionary, object...)?</p>
  
  <pre><code>func showNotification(_ sender: [AnyHashable: Any]) { ... }
  </code></pre>
  
  <blockquote>
    <p>sender["actions"]: </p>
    
    <p>Optional([{"text":"Confirm","type":"response"},{"text":"Decline","type":"response"},{"link":"https://www.stackoverflow.com","text":"Website","type":"info"}])</p>
  </blockquote>
  
  <p>attempts:</p>
  
  <pre><code>if let result = sender["actions"] {
    print("YES \(result)")
    for action in result as! [String] {
      print(action)
    }
  }
  </code></pre>
  
  <p><code>the above prints</code>:</p>
  
  <pre><code>YES [{"text":"Confirm","type":"response"},{"text":"Decline","type":"response"},{"link":"https:\/\/www.stackoverflow.com","text":"Website","type":"info"}]
  </code></pre>
  
  <p>...however, returns the following error:</p>
  
  <p><code>Could not cast value of type '__NSCFString' (0x1a7c28d50) to 'NSArray' (0x1a7c297c8)</code></p>
  
  <p>The end goal here is to simply get to each one of the actions individually, ie:</p>
  
  <p><code>{"text":"Confirm","type":"response"}</code></p>
  
  <p><code>{"text":"Decline","type":"response"</code></p>
  
  <p>ect...</p>
  
  <p>Does Swift have a <code>map</code> function...  FYI Im coming in from a Java and JavaScript world...  <code>swiftyjson</code> seems a bit heavy for one loop.</p>
  
  <p>Thanks, and as always any help and direction is appreciated!</p>
  
  <p><strong>edit:</strong></p>
  
  <p>This is the print via the param passed to the function <code>sender</code>:</p>
  
  <pre><code>sender: [AnyHashable("title"): title!, AnyHashable("message"): message, AnyHashable("message_id"): 0:1503511875428318%03300c3203300c32, AnyHashable("id"): 1497708240713, AnyHashable("actions"): [{"text":"Confirm","type":"response"},{"text":"Decline","type":"response"},{"link":"https:\/\/www.notifyd.com","text":"Website","type":"info"}], AnyHashable("aps"): {
      "content-available" = 1;
  }]
  </code></pre>