title: How do I programmatically populate switch case values?
body: <p>I am pulling in a list of allowed system codes for my case statement via JSON. They are brought in as a string that looks like the following:</p>
  
  <pre><code>let validCodesFromJson:String = "001, 002, 003, 004, 005, 007, 008, 090, 091, 092, 096"
  </code></pre>
  
  <p>I then convert this string into an array with the follwing:</p>
  
  <pre><code>let validCodes:NSArray = validCodesFromJson.componentsSeparatedByString(", ")
  </code></pre>
  
  <p>I need to get this array of codes into the first case of my switch statement.</p>
  
  <pre><code>switch responseArray[selectedResponseTableRow]["code"]! {
          case validCodes:
  
              successfulPostAnimation()
  
          case "006":
  
              showAlertWindow("Alert", message: "Code was 006", buttonText: "OK")
  
          default:
  
             showAlertWindow("Alert", message: "Code was not in the list", buttonText: "OK")
          }
  </code></pre>
  
  <p>The switch statement works if the code is "006" in every other case it is using default. It works fine if I define all of the codes in the first case instead of using the array. But I need to do this programmatically for this project. </p>