Note: I've kept the following in since it still explains a nice way to match multiple dictionary entries, however the intended use case for matching JSON values is better served by using one of the modern JSON Swift libraries like SwityJSON or Argo.

Say you're receiving data from a json frontend. The data converts to a NSDictionary, and then you want to process it. However, this being json and a mystic webservice, you don't know for sure if the dictionary contains all the keys. So the be really sure, you'd like to test for all keys in the dictionary. It is not immediately clear how to do that, but @ nickmain on Twitter (and subsequently Wes Campaigne) came up with a really good solution for this. They're utilizing the switch statement with a tuple to test for multiple entries.

let j2 = ["a": 1, "b": 2, "c": 3] switch (j2["a"], j2["b"], j2["c"]) { case (let a?, nil, nil): print("got \(a)") case (let a?, let b?, .None) where b is String: print("got \(a), \(b)") case (let a?, let b?, let c?): print("got \(a), \(b), \(c)") default: print("got none") }

This prints "got none" because b is not of type string. If the dictionary would be ["b": "45"] then, it would print [got 5, "45"] . This is a really nice solution, because it allows you to test different cases based on the information available in the dictionary. What's more, you can also use the where operator to test for advanced properties of your values. I.e. you can test whether they're of class String, or whether they're above a certain value (i.e. > 5).